http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52590
Bug #: 52590 Summary: std::thread Segmentation fault static linking Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: libstdc++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: ja...@cornsyrup.org $ g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.0~rc1-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.7.0 20120302 (prerelease) (Ubuntu/Linaro 4.7.0~rc1-1ubuntu1) $ g++ -static -pthread -std=c++0x -o thread thread.cc $ ./thread pthread_create works std::thread works Segmentation fault $ cat thread.cc #include <thread> #include <iostream> void *foo1(void *) { std::cout << "pthread_create works\n"; return 0; } void foo2() { std::cout << "std::thread works\n"; } int main() { { pthread_t t; pthread_create(&t, 0, foo1, 0); void *r; pthread_join(t, &r); } { std::thread t(foo2); t.join(); } return 0; } I was surprised to see that pthreads worked in this case while std::thread did not. I've also heard that boost::thread works. I'm having a hard time finding any documentation on whether static linking and std::thread should work together. Also see http://stackoverflow.com/questions/7090623/c0x-thread-static-linking-problem If it is the case that pthreads and std::thread cannot work together with static linking, then it'd be nice to fail at some point before runtime if that is possible.