gcc 5.1.1 requires linkage with -lpthread?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

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 being 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.

Attachment: pgpldTlFJJGNJ.pgp
Description: PGP signature


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux