This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -fuse-ld=gold and -pthread vs -lpthread


On 21/03/17 11:32, John Steele Scott wrote:
> I have a project where linking with "gcc -pthread -fuse-ld=gold ..." fails with errors about undefined pthread symbols, e.g.
> 
> gcc /opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.2.1/crtend.o /usr/lib/../lib64/crtn.o
> /opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.2.1/libstdc++_nonshared.a(thread44.o):function std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()): error: undefined reference to 'pthread_create'
> /opt/rh/devtoolset-6/root/usr/lib/gcc/x86_64-redhat-linux/6.2.1/libstdc++_nonshared.a(thread44.o):function std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>, void (*)()): error: undefined reference to 'pthread_create'

There were a couple of other libraries being linked in which referred to symbols in libpthread, but did not have a DT_NEEDED entry for libpthread. One of these instances was a libtool project bitten by <https://bugzilla.redhat.com/show_bug.cgi?id=661333>, the others could be fixed with simple makefile editing.

Anyhow, after fixing those problems, the above messages disappeared as well. So I've gone back to using -pthread, like I had before. All's well that ends well.

Cheers,

John


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]