Hello everyone,
I am trying to compile LimeSuite (https://github.com/myriadrf/LimeSuite https://wiki.myriadrf.org/Lime_Suite) for BananaPI-R2.
I am using Ubuntu Mate 16.04 2017-11-27 (BPI-R2 new image : ubuntu 16.04 V1.2.1 BT and WIFI AP mode are working fine 2017-11-27)
On Ubuntu 16.04 desktop (x86-64) this project compiles without any problems, while here on BananaPI i get these linking errors:
/usr/bin/ld: CMakeFiles/basicRX.dir/basicRX.cpp.o: undefined reference to symbol '__printf_chk@@GLIBC_2.4'
//lib/arm-linux-gnueabihf/libc.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
src/examples/CMakeFiles/basicRX.dir/build.make:97: recipe for target 'bin/basicRX' failed
make[2]: *** [bin/basicRX] Error 1
CMakeFiles/Makefile2:261: recipe for target 'src/examples/CMakeFiles/basicRX.dir/all' failed
make[1]: *** [src/examples/CMakeFiles/basicRX.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/usr/bin/ld: CMakeFiles/gpio_example.dir/gpio_example.cpp.o: undefined reference to symbol 'exit@@GLIBC_2.4'
//lib/arm-linux-gnueabihf/libc.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
/usr/bin/ld: CMakeFiles/boardEmulator.dir/boardEmulator.cpp.o: undefined reference to symbol '__printf_chk@@GLIBC_2.4'
//lib/arm-linux-gnueabihf/libc.so.6: error adding symbols: DSO missing from command line
src/examples/CMakeFiles/gpio_example.dir/build.make:97: recipe for target 'bin/gpio_example' failed
make[2]: *** [bin/gpio_example] Error 1
collect2: error: ld returned 1 exit status
CMakeFiles/Makefile2:335: recipe for target 'src/examples/CMakeFiles/gpio_example.dir/all' failed
src/CMakeFiles/boardEmulator.dir/build.make:97: recipe for target 'src/boardEmulator' failed
make[1]: *** [src/examples/CMakeFiles/gpio_example.dir/all] Error 2
make[2]: *** [src/boardEmulator] Error 1
CMakeFiles/Makefile2:164: recipe for target 'src/CMakeFiles/boardEmulator.dir/all' failed
make[1]: *** [src/CMakeFiles/boardEmulator.dir/all] Error 2
/usr/bin/ld: CMakeFiles/dualRXTX.dir/dualRXTX.cpp.o: undefined reference to symbol 'exit@@GLIBC_2.4'
//lib/arm-linux-gnueabihf/libc.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
src/examples/CMakeFiles/dualRXTX.dir/build.make:97: recipe for target 'bin/dualRXTX' failed
make[2]: *** [bin/dualRXTX] Error 1
CMakeFiles/Makefile2:298: recipe for target 'src/examples/CMakeFiles/dualRXTX.dir/all' failed
make[1]: *** [src/examples/CMakeFiles/dualRXTX.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error
I really do not understand how can there be problems finding exit() and __printf_chk() symbols, as far as i understand libc is always linked by default, and both exit and printf are in the standard libc library. I’m not sure how to tackle this issue. Using cmake-gui and adding -lc to force linking libc in the cmake configuration (CMAKE_MODULE_LINKER_FLAGS, CMAKE_SHARED_LINKER_FLAGS, CMAKE_STATIC_LINKER_FLAGS) did not help.
Someone had a similar problem while compiling WiringPi (How to: banana pi BPI-M3 install BPI-WiringPi) however, no solution (other than moving to WiringPi2) is mentioned.
Other search results do not seem useful.
Relevant software versions on the bananapi: 1. gcc version: gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 2. ld version: GNU ld (GNU Binutils for Ubuntu) 2.26.1 3. libc version: ldd (Ubuntu GLIBC 2.23-0ubuntu9) 2.23 4. /lib/arm-linux-gnueabihf/libc.so.6 version:GNU C Library (Ubuntu GLIBC 2.23-0ubuntu9) stable release version 2.23
Any help or pointers in the right direction would be greatly appreciated
EDIT: Apparently cmake defaults to using /usr/local/lib as the library path for gcc, while it should be using /lib/arm-linux-gnueabihf. /usr/local/lib/libc.so is actually the musl library, manually linking the boardEmulator.cpp.o file while using -L/lib/arm-linux-gnueabihf fixes all the libc problems, but i can’t simply delete libc.so from there. Is it possible to set GLIBC to be default, instead of Musl libc?
EDIT2: PROBLEM HAS BEEN FIXED I have created a patch for bananapi-r2. Apparently CMAKE finds libusb in /usr/local/lib by default, and then passes the argument -L/usr/local/lib to the linker, while the correct lib location is /lib/arm-linux-gnueabihf.
For compiling on the bananapi-R2, please clone the bananapi-r2-cmake-patch branch, like so:
git clone -b bananapi-r2-cmake-patch https://github.com/myriadrf/LimeSuite.git
and when running cmake, pass -Dbananapi-r2=YES as an argument BEFORE the source folder path:
(builddir)$ cmake -Dbananapi-r2=YES ../
All the other build steps are the same as explained on the myriadrf/LimeSuite wiki. http://wiki.myriadrf.org/Lime_Suite