I am trying to cross-compile OpenCV 4.5.5. My host computer is Ubuntu 20.04. I am getting some issues when generating a runtime search path for some libraries (as far as I understood). It seems that the issue has to do with cmake trying to find some libs under /usr/lib/x86_64-linux-gnu
but not sure how to avoid it. I tried to follow the answer to this question and others, so I added:
-DPATHS=/usr/aarch64-linux-gnu/lib \
-DNO_DEFAULT_PATH:BOOL=ON \
-DNO_CMAKE_SYSTEM_PATH:BOOL=ON \
but it did not work. Following you can find an excerpt of the warnings I am getting (in case you want to see the full output, here is the link):
CMake Warning at cmake/OpenCVUtils.cmake:1547 (add_library):
Cannot generate a safe runtime search path for target opencv_highgui
because files in some directories may conflict with libraries in implicit
directories:
/usr/lib/x86_64-linux-gnu
runtime library [libfreetype.so.6] in /usr/aarch64-linux-gnu/lib may be hidden by files in:
Some of these libraries may not be found correctly.
Call Stack (most recent call first):
cmake/OpenCVModule.cmake:966 (ocv_add_library)
cmake/OpenCVModule.cmake:882 (_ocv_create_module)
modules/highgui/CMakeLists.txt:267 (ocv_create_module)
CMake Warning at cmake/OpenCVUtils.cmake:1536 (add_executable):
Cannot generate a safe runtime search path for target opencv_test_highgui
because files in some directories may conflict with libraries in implicit
directories:
runtime library [libpangocairo-1.0.so.0] in /usr/aarch64-linux-gnu/lib may be hidden by files in:
/usr/lib/x86_64-linux-gnu
For your reference, following is my full cmake command:
export LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib
export PKG_CONFIG_PATH=/usr/aarch64-linux-gnu/lib/pkgconfig
cmake \
-DPATHS=/usr/aarch64-linux-gnu/lib \
-DNO_DEFAULT_PATH:BOOL=ON \
-DNO_CMAKE_SYSTEM_PATH:BOOL=ON \
-DCMAKE_C_COMPILER=/bin/aarch64-linux-gnu-gcc \
-DCMAKE_CXX_COMPILER=/bin/aarch64-linux-gnu-g++ \
-DCMAKE_INSTALL_PREFIX:PATH=/usr/aarch64-linux-gnu \
-DWITH_FREETYPE:BOOL=ON \
-DWITH_CUDA:BOOL=ON \
-DWITH_OPENMP:BOOL=ON \
-DEIGEN_INCLUDE_PATH:PATH=/usr/aarch64-linux-gnu/include/ \
-DCUDA_FAST_MATH:BOOL=ON \
-DENABLE_FAST_MATH:BOOL=ON \
-DOPENCV_DNN_CUDA:BOOL=ON \
-DWITH_OPENNI:BOOL=ON \
-DOPENCV_ENABLE_NONFREE:BOOL=ON \
-DCMAKE_INSTALL_PREFIX:PATH=/usr/aarch64-linux-gnu \
-DOPENCV_ENABLE_NONFREE:BOOL=ON \
-DOPENCV_EXTRA_MODULES_PATH:PATH="/home/alexis/Desktop/dev/jetson_xavier/opencv-4.5.5-openvino-2022.1.0/opencv_contrib/modules" \
-DWITH_FREETYPE:BOOL=1 \
-DWITH_CUDA:BOOL=ON \
-DWITH_OPENMP:BOOL=ON \
-DEIGEN_INCLUDE_PATH:PATH=/usr/aarch64-linux-gnu/include/ \
-DCUDA_FAST_MATH:BOOL=ON \
-DENABLE_FAST_MATH:BOOL=ON \
-DOPENCV_DNN_CUDA:BOOL=ON \
-DWITH_OPENNI:BOOL=ON \
-DWITH_CUDA:BOOL=ON \
-DWITH_TBB:BOOL=ON \
-DWITH_1394:BOOL=0 \
-DBUILD_PNG:BOOL=1 \
../opencv