Strange errors linking libstdc++.so

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

 



Hi all.  I have a locally-built relocatable GCC toolchain (GCC 4.8.0 /
binutils 2.23.2).  By this I mean that the compiler was built to install
into a location that no longer exists and was built against a sysroot
that no longer exists.  All its builtin paths no longer exist on the
system.  The only way the compiler can find anything is if I add the
--sysroot flag to all invocations... which I do.

I'm building some executables and a shared library, then I'm linking the
shared library with some unit test programs, all using this same
compiler with the same value of --sysroot.  I know the --sysroot is
good.

I want the executables to not depend on the version of GCC installed on
the target system so I'm linking them with -static-libgcc
-static-libstdc++ (it's all C++ code, both the executables and shared
library).  This works fine: they link, ldd shows no prerequisites, and
they run fine on all the target platforms even the old ones.  Note that
these executables do NOT link the shared library.

When I build the .so I do _not_ use the -static-* flags and when I use
ldd on the .so I see it referencing the real system libstdc++.  That's
OK.

If I link the unit test programs with the shared library normally by
hand, everything links and works fine.


However it turns out that in my build system it's tricky to get the real
executables to use the -static-* flags but the test programs to NOT use
the -static-* flags... and when I try to link the unit test programs
with the -static-* flags AND with the shared library, I get a ton of
failures (see below).


It's odd to me that linking my exe with -static-* works, and linking
with my shared object without -static-* works, but linking with my
shared object AND with -static-* fails.

Any thoughts?


/.../cc/generic/bin/../lib/gcc/x86_64-generic-linux-gnu/4.8.0/../../../../x86_64-generic-linux-gnu/bin/ld: warning: libstdc++.so.6, needed by ../libSharedLib.so, not found (try using -rpath or -rpath-link)
../libSharedLib.so: undefined reference to `__cxa_allocate_exception@CXXABI_1.3'
../libSharedLib.so: undefined reference to `__cxa_throw@CXXABI_1.3'
../libSharedLib.so: undefined reference to `operator delete(void*)@GLIBCXX_3.4'
../libSharedLib.so: undefined reference to `operator new(unsigned long)@GLIBCXX_3.4'
../libSharedLib.so: undefined reference to `vtable for __cxxabiv1::__class_type_info@CXXABI_1.3'
../libSharedLib.so: undefined reference to `__cxa_end_catch@CXXABI_1.3'
../libSharedLib.so: undefined reference to `__cxa_rethrow@CXXABI_1.3'
../libSharedLib.so: undefined reference to `__cxa_call_unexpected@CXXABI_1.3'
../libSharedLib.so: undefined reference to `__gxx_personality_v0@CXXABI_1.3'
../libSharedLib.so: undefined reference to `__cxa_free_exception@CXXABI_1.3'
../libSharedLib.so: undefined reference to `operator delete[](void*)@GLIBCXX_3.4'
../libSharedLib.so: undefined reference to `typeinfo for std::exception@GLIBCXX_3.4'
../libSharedLib.so: undefined reference to `__dynamic_cast@CXXABI_1.3'
../libSharedLib.so: undefined reference to `vtable for __cxxabiv1::__si_class_type_info@CXXABI_1.3'
../libSharedLib.so: undefined reference to `__cxa_begin_catch@CXXABI_1.3'
../libSharedLib.so: undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info@CXXABI_1.3'
../libSharedLib.so: undefined reference to `operator new[](unsigned long)@GLIBCXX_3.4'
../libSharedLib.so: undefined reference to `__cxa_pure_virtual@CXXABI_1.3'
collect2: error: ld returned 1 exit status






[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