This is bug #22185 in GCC. A GCC Bugmaster commented this may be a bug in the linker, so here I am. The URL for the bug is: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22185 There is a testcase attached to the bug.
It is a gcc bug which has been fixed in CVS. *** This bug has been marked as a duplicate of 1025 ***
BTW, the linker bug is also fixed in CVS.
Reopen.
The problem is caused by #pragma GCC visibility push(hidden) which needs support from glibc and libstdc++ as well as gcc. My modified gcc 4.0 gave: /usr/gcc-4.0/bin/g++ -m32 -O3 -fPIC -c -o net_error.o net_error.ii /usr/gcc-4.0/bin/g++ -m32 -fPIC -shared -o net_error.so net_error.o net_error.o(.text+0x50): In function `boost::network::net_error::net_error()': net_error.cpp: undefined reference to `__errno_location' net_error.o(.text+0x5f):net_error.cpp: undefined reference to `strerror' net_error.o(.text+0x72):net_error.cpp: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)' net_error.o(.text+0x81):net_error.cpp: undefined reference to `std::runtime_error::runtime_error(std::string const&)' net_error.o(.text+0x96):net_error.cpp: undefined reference to `std::string::_Rep::_S_empty_rep_storage' net_error.o(.text+0x22e):net_error.cpp: undefined reference to `__gnu_cxx::__exchange_and_add(int volatile*, int)' net_error.o(.text+0x245):net_error.cpp: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)' net_error.o(.text+0x25d):net_error.cpp: undefined reference to `std::string::_Rep::_S_empty_rep_storage' net_error.o(.text+0x286):net_error.cpp: undefined reference to `__gnu_cxx::__exchange_and_add(int volatile*, int)' net_error.o(.text+0x299):net_error.cpp: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)' net_error.o(.text+0x380): In function `boost::network::net_error::net_error()': net_error.cpp: undefined reference to `__errno_location' net_error.o(.text+0x38f):net_error.cpp: undefined reference to `strerror' net_error.o(.text+0x3a2):net_error.cpp: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)' net_error.o(.text+0x3b1):net_error.cpp: undefined reference to `std::runtime_error::runtime_error(std::string const&)' net_error.o(.text+0x3c6):net_error.cpp: undefined reference to `std::string::_Rep::_S_empty_rep_storage' net_error.o(.text+0x55e):net_error.cpp: undefined reference to `__gnu_cxx::__exchange_and_add(int volatile*, int)' net_error.o(.text+0x575):net_error.cpp: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)' net_error.o(.text+0x58d):net_error.cpp: undefined reference to `std::string::_Rep::_S_empty_rep_storage' net_error.o(.text+0x5b6):net_error.cpp: undefined reference to `__gnu_cxx::__exchange_and_add(int volatile*, int)' net_error.o(.text+0x5c9):net_error.cpp: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)' net_error.o(.gnu.linkonce.d._ZTVN5boost7network9net_errorE[_ZTVN5boost7network9net_errorE]+0x10): undefined reference to `std::runtime_error::what() const' net_error.o(.gnu.linkonce.d._ZTIN5boost7network9net_errorE[_ZTIN5boost7network9net_errorE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info' net_error.o(.gnu.linkonce.d._ZTIN5boost7network9net_errorE[_ZTIN5boost7network9net_errorE]+0x8): undefined reference to `typeinfo for std::runtime_error' net_error.o(.gnu.linkonce.t._ZN5boost7network9net_errorD1Ev[_ZN5boost7network9net_errorD1Ev]+0x21): In function `boost::network::net_error::~net_error()': net_error.cpp: undefined reference to `std::runtime_error::~runtime_error()' net_error.o(.gnu.linkonce.t._ZN5boost7network9net_errorD0Ev[_ZN5boost7network9net_errorD0Ev]+0x26): In function `boost::network::net_error::~net_error()': net_error.cpp: undefined reference to `std::runtime_error::~runtime_error()' net_error.o(.gnu.linkonce.t._ZN9__gnu_cxx20__common_pool_policyINS_6__poolELb1EE21_S_destroy_thread_keyEPv[_ZN9__gnu_cxx20__common_pool_policyINS_6__poolELb1EE21_S_destroy_thread_keyEPv]+0x37): In function `__gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true>::_S_destroy_thread_key(void*)': net_error.cpp: undefined reference to `__gnu_cxx::__pool<true>::_M_destroy_thread_key(void*)' net_error.o(.gnu.linkonce.t._ZN9__gnu_cxx20__common_pool_policyINS_6__poolELb1EE21_S_destroy_thread_keyEPv[_ZN9__gnu_cxx20__common_pool_policyINS_6__poolELb1EE21_S_destroy_thread_keyEPv]+0xf5):net_error.cpp: undefined reference to `__gnu_cxx::__pool<true>::_M_destroy_thread_key(void*)' net_error.o(.gnu.linkonce.t._ZN9__gnu_cxx20__common_pool_policyINS_6__poolELb1EE13_S_initializeEv[_ZN9__gnu_cxx20__common_pool_policyINS_6__poolELb1EE13_S_initializeEv]+0x3a): In function `__gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true>::_S_initialize()': net_error.cpp: undefined reference to `__gnu_cxx::__pool<true>::_M_initialize(void (*)(void*))' net_error.o(.gnu.linkonce.t._ZN9__gnu_cxx20__common_pool_policyINS_6__poolELb1EE13_S_initializeEv[_ZN9__gnu_cxx20__common_pool_policyINS_6__poolELb1EE13_S_initializeEv]+0xfb):net_error.cpp: undefined reference to `__gnu_cxx::__pool<true>::_M_initialize(void (*)(void*))' /usr/bin/ld: net_error.so: hidden symbol `strerror' isn't defined /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: ld returned 1 exit status
Fixed. Now I get gcc -fPIC -O2 -g -c -o foo.o foo.c gcc -shared -o libfoo.so foo.o gcc -fPIC -O2 -g -c -o x.o x.c gcc -shared -o libx.so x.o gcc -fPIC -O2 -g -c -o y.o y.c gcc -o y1 y.o x.o libfoo.so -Wl,-rpath,. /usr/local/bin/ld: x.o(.text+0x11): unresolvable R_386_GOTOFF relocation against symbol `foo' /usr/local/bin/ld: final link failed: Nonrepresentable section on output collect2: ld returned 1 exit status make: *** [y1] Error 1