Description:
I am trying to cross-compile OpenCV for my Raspberry Pi, which is running Ubuntu 20.04 LTS with aarch64 architecture. My development machine is x86_64 running on Ubuntu 20.04 LTS, and I am using Docker to manage the build environment. Several dependencies have been built from source.
Version Info:
OpenCV Version: 4.5.1
Dependencies built from Source:
Eigen, Boost, GRPC, Glog, Gflags, OpenBLAS, Ceres, JPEG,
TIFF, WEBP, PNG, Neon, VPX, xVid, x264, FFMPEG
Host Software and Arch :
Ubuntu 20.04 LTS,
x86_64
Target Software and Arch:
Ubuntu 20.04 LTS,
Aarch64
Problem:
Running Cmake on OpenCV fails with the following log:
#52 601.4 [ 86%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/cpu/gcpuimgproc.cpp.o
#52 601.4 [ 86%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/test/test_main.cpp.o
#52 601.5 [ 86%] Linking CXX shared library ../../lib/libopencv_sfm.so
#52 601.9 /usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: ../../lib/libcorrespondence.a(nRobustViewMatching.cc.o): in function `libmv::correspondence::nRobustViewMatching::computeData(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
#52 601.9 nRobustViewMatching.cc:(.text._ZN5libmv14correspondence19nRobustViewMatching11computeDataERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x54): undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
#52 601.9 collect2: error: ld returned 1 exit status
#52 601.9 make[2]: *** [modules/sfm/CMakeFiles/opencv_sfm.dir/build.make:225: lib/libopencv_sfm.so.4.5.1] Error 1
#52 601.9 make[1]: *** [CMakeFiles/Makefile2:7987: modules/sfm/CMakeFiles/opencv_sfm.dir/all] Error 2
#52 601.9 make[1]: *** Waiting for unfinished jobs....
Which seems to be a linking issue
Disabling Ceres build from source stops the problem but Ceres is a required dependency for my build
Reproduce the Issue:
Here is a link to the Dockerfile im using to run the build:
https://github.com/JatinVira/Docker_File/blob/main/Dockerfile
This is a link to the Cmake toolchain file that im using:
https://github.com/JatinVira/Docker_File/blob/main/rpi_aarch64.cmake
Cmake Log:
This is the Cmake Summary before build starts:
#52 36.90 -- General configuration for OpenCV 4.5.1 =====================================
#52 36.90 -- Version control: 4.5.1
#52 36.90 --
#52 36.90 -- Extra modules:
#52 36.96 -- Location (extra): /root/opencv_build/opencv_contrib/modules
#52 36.96 -- Version control (extra): 4.5.1
#52 36.96 --
#52 36.96 -- Platform:
#52 36.96 -- Timestamp: 2023-11-15T12:37:25Z
#52 36.96 -- Host: Linux 5.15.0-88-generic x86_64
#52 36.96 -- Target: Linux 1 aarch64
#52 36.96 -- CMake: 3.16.3
#52 36.96 -- CMake generator: Unix Makefiles
#52 36.96 -- CMake build tool: /usr/bin/make
#52 36.96 -- Configuration: Release
#52 36.96 --
#52 36.96 -- CPU/HW features:
#52 36.96 -- Baseline: NEON FP16
#52 36.96 -- required: NEON
#52 36.96 -- disabled: VFPV3
#52 36.96 --
#52 36.96 -- C/C++:
#52 36.96 -- Built as dynamic libs?: YES
#52 36.96 -- C++ standard: 11
#52 36.96 -- C++ Compiler: /usr/bin/aarch64-linux-gnu-g++ (ver 9.4.0)
#52 36.96 -- C++ flags (Release): -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fPIC -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
#52 36.96 -- C++ flags (Debug): -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fPIC -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
#52 36.96 -- C Compiler: /usr/bin/aarch64-linux-gnu-gcc
#52 36.96 -- C flags (Release): -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fPIC -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
#52 36.97 -- C flags (Debug): -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fPIC -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi -fPIC -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
#52 36.97 -- Linker flags (Release): -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,--as-needed
#52 36.97 -- Linker flags (Debug): -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,--as-needed
#52 36.97 -- ccache: YES
#52 36.97 -- Precompiled headers: NO
#52 36.98 -- Extra dependencies: dl m pthread rt
#52 36.98 -- 3rdparty dependencies:
#52 36.98 --
#52 36.98 -- OpenCV modules:
#52 36.99 -- To be built: alphamat aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
#52 36.99 -- Disabled: world
#52 36.99 -- Disabled by dependency: -
#52 36.99 -- Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf java julia matlab ovis python2 python3 viz xfeatures2d
#52 36.99 -- Applications: tests perf_tests apps
#52 36.99 -- Documentation: NO
#52 36.99 -- Non-free algorithms: NO
#52 36.99 --
#52 36.99 -- GUI:
#52 36.99 -- GTK+: NO
#52 36.99 --
#52 36.99 -- Media I/O:
#52 36.99 -- ZLib: /usr/aarch64-linux-gnu/lib/libz.so (ver 1.2.12)
#52 36.99 -- JPEG: /usr/aarch64-linux-gnu/lib/libjpeg.so (ver 90)
#52 36.99 -- WEBP: /usr/aarch64-linux-gnu/lib/libwebp.so (ver encoder: 0x020f)
#52 36.99 -- PNG: /usr/aarch64-linux-gnu/lib/libpng.so (ver 1.6.37)
#52 36.99 -- TIFF: /usr/aarch64-linux-gnu/lib/libtiff.so (ver 42 / 4.3.0)
#52 36.99 -- JPEG 2000: build (ver 2.3.1)
#52 36.99 -- HDR: YES
#52 36.99 -- SUNRASTER: YES
#52 36.99 -- PXM: YES
#52 36.99 -- PFM: YES
#52 36.99 --
#52 36.99 -- Video I/O:
#52 36.99 -- DC1394: NO
#52 36.99 -- FFMPEG: NO
#52 36.99 -- avcodec: YES (58.91.100)
#52 36.99 -- avformat: YES (58.45.100)
#52 36.99 -- avutil: YES (56.51.100)
#52 36.99 -- swscale: YES (5.7.100)
#52 36.99 -- avresample: NO
#52 36.99 -- GStreamer: NO
#52 36.99 -- v4l/v4l2: YES (linux/videodev2.h)
#52 36.99 --
#52 36.99 -- Parallel framework: pthreads
#52 36.99 --
#52 36.99 -- Trace: YES (with Intel ITT)
#52 36.99 --
#52 36.99 -- Other third-party libraries:
#52 36.99 -- Lapack: YES (/usr/aarch64-linux-gnu/lib/libopenblas.so)
#52 36.99 -- Eigen: YES (ver 3.3.7)
#52 36.99 -- Custom HAL: YES (carotene (ver 0.0.1))
#52 36.99 -- Protobuf: build (3.5.1)
#52 36.99 --
#52 36.99 -- OpenCL: YES (no extra features)
#52 36.99 -- Include path: /root/opencv_build/opencv/3rdparty/include/opencl/1.2
#52 36.99 -- Link libraries: Dynamic load
#52 36.99 --
#52 36.99 -- Python (for build): /usr/bin/python2.7
#52 36.99 --
#52 36.99 -- Install to: /usr/aarch64-linux-gnu
#52 36.99 -- -----------------------------------------------------------------
#52 36.99 --
#52 37.41 -- Configuring done
#52 37.98 -- Generating done
#52 38.01 -- Build files have been written to: /root/opencv_build/opencv/build
so you succesfully installed opencv ?