g++ linking broken without -lpthread
testcase hello.cc:
#include <iostream>
int main(void)
{
std::string mystring = "hello";
std::cout << mystring;
return 0;
}
compiling with g -lpthread hello.cc works.
compiling without -lpthread gives:
/usr/lib/gcc/i486-alpine-linux-uclibc/4.6.2/../../../../i486-alpine-linux-uclibc/bin/ld: /lib/librt.so.0.9.32: undefined reference to symbol 'pthread_cancel'
/usr/lib/gcc/i486-alpine-linux-uclibc/4.6.2/../../../../i486-alpine-linux-uclibc/bin/ld: note: 'pthread_cancel' is defined in DSO /lib/libpthread.so.0.9.32 so try adding it to the linker command line
/lib/libpthread.so.0.9.32: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
This happened with the binutils-2.22 upgrade.
This affects at least squid (when compiling cf_gen) and boost.
(from redmine: issue id 854, created on 2011-12-05, closed on 2012-01-05)
- Changesets:
- Revision df7fc5c4 by Natanael Copa on 2011-12-05T15:18:20Z:
main/libc0.9.32: remove the librt as-needed fix
We should really fix the broken apps instead as suggested by upstream
This also fixes issue with c++ apps linking in librt when they shouldn't.
gcc needs to be rebuilt with a libstdc++ thats not linked to librt.
ref #854
- Revision 94b1ce30 by Natanael Copa on 2011-12-05T15:27:20Z:
main/gcc: bump pkgrel so we actually get the libquadmath split
This also helps us with the librt-as-needed revert.
fixes #854