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.