Search code examples
makefilecross-compilingubuntu-18.04glibcarmv7

GLIBC error: Cross-compiling ARMNN on x86_64 (Ubuntu18.04) for ARM Cortex A9(Debian 9)


I cross-compiled ARMNN for my ARM Cortex-A9 (Debian 9) device on my host system which is x86_64 (Ubuntu 18.04).

I have successfully built ARMNN and all it's dependencies without any errors, but when I try to run the sample mnist on Cortex-A9, it gives the following error:

duu@34d456-45433g:~/ML-examples/armnn-mnist$ make test
arm-linux-gnueabihf-g++ -O3 -std=c++14 -I/home/duu/armnn/armnn/include mnist_caffe.cpp -o mnist_caffe -L/home/duu/build -larmnn -larmnnCaffeParser
/home/admin/build/libarmnn.so: undefined reference to `exp2f@GLIBC_2.27'
/home/admin/build/libarmnn.so: undefined reference to `logf@GLIBC_2.27'
/home/admin/build/libarmnn.so: undefined reference to `log2f@GLIBC_2.27'
/home/admin/build/libarmnn.so: undefined reference to `powf@GLIBC_2.27'
/home/admin/build/libarmnn.so: undefined reference to `expf@GLIBC_2.27'
collect2: error: ld returned 1 exit status
Makefile:12: recipe for target 'mnist_caffe' failed
make: *** [mnist_caffe] Error 1

I figured later that the device should have the same compiler and same GLIBC package, both with same versions as the host on which the library was compiled.

I compiled ARMNN using gcc-6.4.0 and glibc-2.27 on the host and I have gcc-6.3.0 and glibc-2.24 on Cortex-A9 device.

I managed to match the GCC versions and solve the compiler error but I am not able to find matching versions of GLIBC on Ubuntu 18.04 and debian 9.

Is there any way to install a GLIBC version on either of the systems which is common for both of them?

P.S. : Any other method to solve this issue is highly appreciated.


Solution

  • Here is a list of the possible options I can think of right now:

    1. run your application while having LD_LIBRARY_PATH pointing to a directory containing the arm glibc dynamic libraries(v2.27) copied from your x86_64 system - see this post.
    2. Re-compile your application on your target system, if possible, if your target system can use NFS for example,
    3. cross-compile a static version of your library/application, linking it using -static -static-libgcc -static-libstdc++ - see this post.
    4. use arm-linux-musleabihf-cross or one of his friends for cross-compiling a static version of your library/application if this did not work with gcc/g++ and glibc.
    5. run your application in a chrooted environment containing the arm dynamic libraries you linked your application with on the x86_64 system - see this post for more details,
    6. install docker on your Cortex-A9 system, and build a minimal debian/ubuntu docker image that contain a version of debian/ubuntu using glibc 2.27, along with your library and application, and execute the application in a container.