If you're using std::thread then you always needed to link to libpthread or you'd get an exception at run time. Now you get a failure earlier at link time, but there's no new dependency. On Jun 6, 2015 6:24 PM, "Sam Varshavchik" <mrsam@xxxxxxxxxxxxxxx> wrote: > Rebuilding a bunch of code from 4.9.2 to 5.1.1 resulted in a bunch of > complaints about unresolved references to pthread_create(), and admonishing > me for not linking with -lpthread :-) > > Which was odd, since the code in question uses std::thread exclusively, > and should only need to be linked with the default libstdc++, helpfully > supplied by the compiler. > No. Libstdc++ never linked to libpthread, it was always your job. > So, I chased this down to <thread> now making visible an explicit > reference to pthread_create, in std::thread's constructor: > > template<typename _Callable, typename… _Args> > explicit > thread(_Callable&& __f, _Args&&… __args) > { > _M_start_thread(_M_make_routine(std::__bind_simple( > std::forward<_Callable>(__f), > std::forward<_Args>(__args)…)), > reinterpret_cast<void(*)()>(&pthread_create)); > } > > So that's what I'm compiling. This may be because of the ld.so > configuration in Fedora. Even if libstdc++ is linked with -lpthread, this > ends up b compiled as part of my code, at -O2, apparently, and I'm not > linking with -lpthread. > > Not really a complicated thing to fix up, of course. Just seems a bit odd, > to end up requiring a linking dependency, in this manner. > >