arm-angstrom-linux-gnueabi-gcc linker fails to link against uclibc

1.6k views Asked by At

I am trying to build an application for angstrom linux (that uses uclibc instead of libstdc++, in my case). I am using bitbake and openembedded. With a simple toolchain I am able to build successfully by adding only -muclibc flag. With bitbake my build command is the following

arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp -mthumb-interwork -mno-thumb --sysroot=/home/hnsl/stuff/tmp/sysroots/armv7a-angstrom-linux-gnueabi -fexpensive-optimizations -fomit-frame-pointer -frename-registers -O2 -ggdb2 -Wl,-O1 -Wl,--hash-style=gnu -muclibc mainThread.cpp lib.cpp -lportaudio

where -muclibc mainThread.cpp lib.cpp -lportaudio is done by me. Portaudio (-lportaudio) is linked successfully. Uclibc (I think) fails to be linked; I get these errors:

 /tmp/ccW4SVb4.o: In function `main':
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/mainThread.cpp:68: undefined reference to `__cxa_end_cleanup'
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/mainThread.cpp:68: undefined reference to `__cxa_begin_catch'
| /tmp/ccW4SVb4.o: In function `operator<< <std::char_traits<char> >':
| /home/hnsl/stuff/tmp/sysroots/x86_64-linux/usr/armv7a/lib/gcc/arm-angstrom-linux-gnueabi/4.5.3/../../../../arm-angstrom-linux-gnueabi/include/c++/4.5.3/ostream:513: undefined reference to `std::cerr'
| /home/hnsl/stuff/tmp/sysroots/x86_64-linux/usr/armv7a/lib/gcc/arm-angstrom-linux-gnueabi/4.5.3/../../../../arm-angstrom-linux-gnueabi/include/c++/4.5.3/ostream:513: undefined reference to `std::cerr'
| /home/hnsl/stuff/tmp/sysroots/x86_64-linux/usr/armv7a/lib/gcc/arm-angstrom-linux-gnueabi/4.5.3/../../../../arm-angstrom-linux-gnueabi/include/c++/4.5.3/ostream:513: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)'
| /tmp/ccW4SVb4.o: In function `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))':
| /home/hnsl/stuff/tmp/sysroots/x86_64-linux/usr/armv7a/lib/gcc/arm-angstrom-linux-gnueabi/4.5.3/../../../../arm-angstrom-linux-gnueabi/include/c++/4.5.3/ostream:113: undefined reference to `std::cerr'
| /home/hnsl/stuff/tmp/sysroots/x86_64-linux/usr/armv7a/lib/gcc/arm-angstrom-linux-gnueabi/4.5.3/../../../../arm-angstrom-linux-gnueabi/include/c++/4.5.3/ostream:113: undefined reference to `std::cerr'
| /home/hnsl/stuff/tmp/sysroots/x86_64-linux/usr/armv7a/lib/gcc/arm-angstrom-linux-gnueabi/4.5.3/../../../../arm-angstrom-linux-gnueabi/include/c++/4.5.3/ostream:113: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
| /tmp/ccW4SVb4.o: In function `main':
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/mainThread.cpp:68: undefined reference to `__cxa_end_catch'
| /tmp/ccW4SVb4.o: In function `operator<< <std::char_traits<char> >':
| /home/hnsl/stuff/tmp/sysroots/x86_64-linux/usr/armv7a/lib/gcc/arm-angstrom-linux-gnueabi/4.5.3/../../../../arm-angstrom-linux-gnueabi/include/c++/4.5.3/ostream:511: undefined reference to `std::cerr'
| /home/hnsl/stuff/tmp/sysroots/x86_64-linux/usr/armv7a/lib/gcc/arm-angstrom-linux-gnueabi/4.5.3/../../../../arm-angstrom-linux-gnueabi/include/c++/4.5.3/ostream:511: undefined reference to `std::cerr'
| /tmp/ccW4SVb4.o: In function `std::basic_ios<char, std::char_traits<char> >::setstate(std::_Ios_Iostate)':
| /home/hnsl/stuff/tmp/sysroots/x86_64-linux/usr/armv7a/lib/gcc/arm-angstrom-linux-gnueabi/4.5.3/../../../../arm-angstrom-linux-gnueabi/include/c++/4.5.3/bits/basic_ios.h:148: undefined reference to `std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)'
| /tmp/ccW4SVb4.o: In function `main':
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/mainThread.cpp:68: undefined reference to `__cxa_end_catch'
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/mainThread.cpp:68: undefined reference to `__cxa_end_cleanup'
| /tmp/ccW4SVb4.o: In function `__static_initialization_and_destruction_0':
| /home/hnsl/stuff/tmp/sysroots/x86_64-linux/usr/armv7a/lib/gcc/arm-angstrom-linux-gnueabi/4.5.3/../../../../arm-angstrom-linux-gnueabi/include/c++/4.5.3/iostream:73: undefined reference to `std::ios_base::Init::Init()'
| /home/hnsl/stuff/tmp/sysroots/x86_64-linux/usr/armv7a/lib/gcc/arm-angstrom-linux-gnueabi/4.5.3/../../../../arm-angstrom-linux-gnueabi/include/c++/4.5.3/iostream:73: undefined reference to `std::ios_base::Init::~Init()'
| /home/hnsl/stuff/tmp/sysroots/x86_64-linux/usr/armv7a/lib/gcc/arm-angstrom-linux-gnueabi/4.5.3/../../../../arm-angstrom-linux-gnueabi/include/c++/4.5.3/iostream:73: undefined reference to `std::ios_base::Init::~Init()'
| /tmp/ccW4SVb4.o:(.ARM.extab+0x0): undefined reference to `__gxx_personality_v0'
| /tmp/ccW4SVb4.o:(.ARM.extab+0x28): undefined reference to `typeinfo for char const*'
| /tmp/ccUEShoN.o: In function `endOnError(void*, int, char*)':
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/lib.cpp:23: undefined reference to `__cxa_allocate_exception'
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/lib.cpp:23: undefined reference to `typeinfo for char const*'
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/lib.cpp:23: undefined reference to `typeinfo for char const*'
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/lib.cpp:23: undefined reference to `__cxa_throw'
| /tmp/ccUEShoN.o: In function `initFramework(char**, void**, PaStreamParameters*, PaStreamParameters*)':
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/lib.cpp:32: undefined reference to `__cxa_allocate_exception'
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/lib.cpp:32: undefined reference to `typeinfo for char const*'
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/lib.cpp:32: undefined reference to `typeinfo for char const*'
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/lib.cpp:32: undefined reference to `__cxa_throw'
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/lib.cpp:37: undefined reference to `__cxa_allocate_exception'
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/lib.cpp:37: undefined reference to `typeinfo for char const*'
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/lib.cpp:37: undefined reference to `typeinfo for char const*'
| /home/hnsl/stuff/tmp/work/armv7a-angstrom-linux-gnueabi/cphone-1.0.0-r1/lib.cpp:37: undefined reference to `__cxa_throw'
| collect2: ld returned 1 exit status

Thanks

1

There are 1 answers

0
Mat On BEST ANSWER

You really should use g++ to compile and link C++ code. It will take care of adding the right include paths and linker options for the standard C++ library.

It is possible to do so with gcc, but always using g++ both for compile and link is much easier.