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

Bug#763369: g++-4.9: Linker failure when using str::thread



Hi,

>> $ g++ -std=c++11 threadtest.cpp -o threadtest
>> /tmp/cc2mc1l4.o: In function `std::thread::thread<void (*)()>(void (*&&)())':
>> threadtest.cpp:(.text._ZNSt6threadC2IPFvvEIEEEOT_DpOT0_[_ZNSt6threadC5IPFvvEIEEEOT_DpOT0_]+0x1e): undefined reference to `pthread_create'
>> collect2: error: ld returned 1 exit status
>>
>> The program used to compile and run just fine around a month ago.
>> The problem also affects clang++. I will attach a small example program.
>>
>> The program compiles and runs fine when I add "-pthread" to the flags
>> (this work-around applies to both g++ and clang++). However, it was
>> my understanding (and expectation) that this flag is no longer needed
>> with C++11 - in fact, I shouldn't even know that it's pthreads
>> implementing the std::thread class.
> 
> this is expected behaviour now. You have to link with -pthread.

So even though C++11 is supposed to abstract away from
platform-specific details, I still have to know which threading library
is used internally by my libstdc++? I don't think that's well
though-out, but I understand that this is not your decision but an
upstream one.
Oh well :-/

Kind regards
Ralf


Reply to: