1

I'm trying to cross-compile OpenCV 4.5.1 for ARM targets. My host system is Linux 20.04 (based on Intel). I'm using CMake 3.16.3. Compilation without extra modules works fine. When I add them, I get a linking error towards the end:

[ 86%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/api/kernels_video.cpp.o
[ 86%] Linking CXX executable ../../../../bin/opencv_waldboost_detector
/home/alexis/Desktop/snapdragon/cross/lib/gcc/arm-linux-gnueabi/8.1.0/../../../../arm-linux-gnueabi/bin/ld: warning: libdl.so.2, needed by ../../../../lib/libopencv_core.so.4.5.1, not found (try using -rpath or -rpath-link)
/home/alexis/Desktop/snapdragon/cross/lib/gcc/arm-linux-gnueabi/8.1.0/../../../../arm-linux-gnueabi/bin/ld: warning: librt.so.1, needed by ../../../../lib/libopencv_core.so.4.5.1, not found (try using -rpath or -rpath-link)
../../../../lib/libopencv_core.so.4.5.1: undefined reference to `dladdr@GLIBC_2.4'
../../../../lib/libopencv_core.so.4.5.1: undefined reference to `dlclose@GLIBC_2.4'
../../../../lib/libopencv_core.so.4.5.1: undefined reference to `dlopen@GLIBC_2.4'
../../../../lib/libopencv_core.so.4.5.1: undefined reference to `dlsym@GLIBC_2.4'
../../../../lib/libopencv_core.so.4.5.1: undefined reference to `clock_gettime@GLIBC_2.4'
collect2: error: ld returned 1 exit status

I understand that the issue is because the two libraries libdl and librt cannot be found. The missing libraries are on a non standard path. I tried to set the LD_LIBRARY_PATH to the folder that contains the requested libraries but with no luck.

Not sure what else I could try. The error messages says to try using -rpath or -rpath-link, but I don't know how to do that.

Alexis
  • 576
  • 1
  • 10
  • 29
  • LD_LIBRARY_PATH is for **running** programs. Ie, it is `ld` the Linux program loader which processes this environment variable. You need to pass a `-L` to the link phase to add this. Apparently done with `link_directories(directory_or_variable)` as per [Cmake Library path](https://stackoverflow.com/questions/28597351/how-do-i-add-a-library-path-in-cmake) – artless noise Jan 30 '21 at 21:02
  • Hi, thank you for your answer. Since I'm using cmake-gui, I tried to set the variable CMAKE_LIBRARY_PATH with the path of the folder that contains the libraries I need. I'm not sure if what I did corresponds to what you are suggesting. If not, sorry for my misunderstanding. Anyway, it does not work. Going back to the errors I'm getting, I see that they refer to version 2.4 of GLIBC. I have cross compiled a more recent version of it (v2.27). Is it possible that the error is caused by this? – Alexis Jan 31 '21 at 17:46

0 Answers0