https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62192
Bug ID: 62192 Summary: Segmentation fault when linking with Qt libraries Product: gcc Version: 4.7.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lakjdsfiudslkfj at mailinator dot com Created attachment 33363 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33363&action=edit gdb backtrace Hi, I'm currently having some difficulties linking to my library when my main executable is linked with some Qt libraries. I'm running FreeBSD 10 and gcc47 but the latest 410 package for FreeBSD exhibits the same behavior. My main.cc looks like this: --- #include "foo.h" int main() { foo(); } --- My library libfoo consists of a file foo.cc: --- #include <string> #include <iostream> void foo() { std::string lol = "test"; std::cout << lol << std::endl;; } --- foo.h for completeness: -- void foo(); -- and is compiled via g++ -g -c -fPIC foo.cc -o libfoo.o g++ -shared -fPIC libfoo.o -o libfoo.so After this my main.cc is compiled/linked: g++ -g -O0 -I/tmp/delme2 -DQT_SHARED -I/usr/local/include/qt4 -I/usr/local/include/qt4/QtCore -L/usr/local/lib/qt4 -lQtCore -L/tmp/delme2 -lfoo main.cc running a.out yields "segmentation fault (core dumped) ./a.out" with clang++ -g -O0 -I/tmp/delme2 -DQT_SHARED -I/usr/local/include/qt4 -I/usr/local/include/qt4/QtCore -L/usr/local/lib/qt4 -lQtCore -L/tmp/delme2 -lfoo main.cc the output is "test" as expected. It also works when I remove the Qt libraries, i.e. g++ -g -O0 -I/usr/local/include -I/tmp/delme2 -L/tmp/delme2 -lfoo main.cc Am I doing something wrong here? Is it a Qt problem rather than gcc? But why does it work with clang then? I attached a GDB backtrace just in case.