Cross-compiling error while using OpenCV in sample_camera application

Please provide the following info (check/uncheck the boxes after creating this topic):
Software Version
DRIVE OS Linux 5.2.6
DRIVE OS Linux 5.2.6 and DriveWorks 4.0
DRIVE OS Linux 5.2.0
[*] DRIVE OS Linux 5.2.0 and DriveWorks 3.5
NVIDIA DRIVE™ Software 10.0 (Linux)
NVIDIA DRIVE™ Software 9.0 (Linux)
other DRIVE OS version
other

Target Operating System
[*] Linux
QNX
other

Hardware Platform
NVIDIA DRIVE™ AGX Xavier DevKit (E3550)
[*] NVIDIA DRIVE™ AGX Pegasus DevKit (E3550)
other

SDK Manager Version
[*] 1.8.0.10363
other

Host Machine Version
[*] native Ubuntu 18.04
other

Hi,

I’m trying to cross compile the sample_camera application by using opencv.
During build I’m getting the following errors:

  1. /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h:72:16: error: conflicting

declaration ‘typedef __fp16 float16_t’

typedef __fp16 float16_t;

  1. In file included from /usr/local/driveworks-3.5/samples/src/framework/…/framework/MouseView3D.hpp:34:0,
    from /usr/local/driveworks-3.5/samples/src/framework/…/framework/DriveWorksSample.hpp:43,
    from /usr/local/driveworks-3.5/samples/src/sensors/camera/camera/main.cpp:31:
    /usr/local/driveworks-3.5/targets/aarch64-Linux/include/dw/core/Types.h:75:16: note: previous declaration as ‘typedef struct __half float16_t’
    typedef __half float16_t;

  2. /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h: In function ‘float16x4_t

vld1_f16(const float16_t*)’:

/home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h:17054:40: error: cannot co

nvert ‘const float16_t* {aka const __half*}’ to ‘const __fp16*’ for argument ‘1’ to ‘__vector(4) __fp16 __builtin_aarch64_ld1v4hf(const __fp16*)’

return __builtin_aarch64_ld1v4hf (__a);

I’m attaching a file having the complete stack trace of build errors.

Here is the build error stack trace.
error.txt (53.1 KB)

Hi @raji

Please always search if any topics in the forum are related to your issue. e.g.

Thanks.

Hi @VickNV ,

Thanks for the reference but it doesn’t solve all the issues and also creates different kinds of issues. So could you please provide a working arm_neon.h file which doesn’t throw any error if we include opencv.hpp during cross compilation of an DW application.

I’m not able to understand how to fix these issues.

The below mentioned file throws errors if I’m trying to resolve any issue: DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h

Now it is throwing the below erros:

  1. /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h: In function ‘float16x8_t vget_lane_f16(float16x4_t, int)’:
    /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h:3136:10: error: cannot convert ‘__fp16’ to ‘float16x8_t {aka __vector(8) __fp16}’ in return
    return __aarch64_vget_lane_any (__a, __b);
    ^

  2. /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h: In function ‘float16x8_t vgetq_lane_f16(float16x8_t, int)’:
    /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h:3236:10: error: cannot convert ‘__fp16’ to ‘float16x8_t {aka __vector(8) __fp16}’ in return
    return __aarch64_vget_lane_any (__a, __b);

       ^
    
  3. /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h: At global scope:
    /usr/local/driveworks-3.5/samples/src/sensors/camera/camera/main.cpp:30:19: error: ‘opencv_broken_float16_t’ does not name a type
    #define float16_t opencv_broken_float16_t
    ^

  4. In file included from /usr/include/opencv4/opencv2/core/cvdef.h:222:0,
    from /usr/include/opencv4/opencv2/core.hpp:52,
    from /usr/include/opencv4/opencv2/highgui.hpp:46,
    from /usr/local/driveworks-3.5/samples/src/sensors/camera/camera/main.cpp:31:
    /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h:10984:1: error: using typedef-name ‘float16x3_t’ after ‘struct’
    __STRUCTN (float, 16, 3)
    ^

  5. /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h:72:16: note: ‘float16x3_t’ has a previous declaration here
    typedef __fp16 float16x3_t;
    ^~~~~~~~~~~

  6. /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h:10984:1: error: conflicting declaration ‘typedef int float16x3_t’
    __STRUCTN (float, 16, 3)
    ^

  7. /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h:72:16: note: previous declaration as ‘typedef __fp16 float16x3_t’
    typedef __fp16 float16x3_t;
    ^~~~~~~~~~~

  8. In file included from /usr/include/opencv4/opencv2/core/cvdef.h:222:0,
    from /usr/include/opencv4/opencv2/core.hpp:52,
    from /usr/include/opencv4/opencv2/highgui.hpp:46,
    from /usr/local/driveworks-3.5/samples/src/sensors/camera/camera/main.cpp:31:
    /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h:31301:1: error: expected unqualified-id before ‘extension
    extension extern __inline float16x4_t
    ^~~~~~~~~~~~~

  9. /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h:31308:1: error: expected unqualified-id before ‘extension
    extension extern __inline float16x8_t
    ^~~~~~~~~~~~~

  10. /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h:31363:1: error: expected unqualified-id before ‘extension
    extension extern __inline float16x4_t
    ^~~~~~~~~~~~~

  11. /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h:31370:1: error: expected unqualified-id before ‘extension
    extension extern __inline float16x8_t
    ^~~~~~~~~~~~~

  12. /home/lidar/Documents/Nvidia_Drive/DRIVE_OS_5.2.0_SDK_Linux_OS_DRIVE_AGX_XAVIER/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/7.3.1/include/arm_neon.h:31377:1: error: expected unqualified-id before ‘extension
    extension extern __inline float16x3_t

Attached is my arm_neon.h file.

Please let me know what all changes I need to do in order for compilation to work correctly.
arm_neon.h (986.5 KB)

Please try disabling arm_neon header file in your applicaiton. Thanks.

Hi @VickNV ,

The above issues are resolved but now I’m facing linking error. Please advice how to resolve.
I’ attaching the build error and CMakeLists.txt.
Also the script using which I’m cross-compiling it.

build.sh (593 Bytes)

CMakeLists.txt (8.0 KB)

error.txt (23.0 KB)

Maybe you can check why there is no opencv library directories.

OPENCV_LIBRARY_DIRS:

Also, if you can sahare back how you resolved the previous issus, it will help other developers encountering them in the future. Thanks.

Hi @VickNV ,

Thanks for the advice. I was able to rectify this by re-installing OpenCV c++.
I changed the below files to rectify the previous issues of referring to arm_neon and neon_utils header:

  1. …/opencv2/core/base.hpp
  2. …/opencv2/core/cv_cpu_dispatch.hpp

In both the files I commented out all references to
#include <arm_neon.h> and #include <neon_utils.h> files.

Attaching both the modified files here for future reference.

cv_cpu_dispatch.h (8.1 KB)
base.hpp (26.0 KB)

Coming to the current issue during make that I’m facing is shown below:


[100%] Linking CXX executable sample_camera
CMakeFiles/sample_camera.dir/main.cpp.o: In function `CameraCustomSimpleApp::frameGrab(dwImageObject*, unsigned int)':
main.cpp:(.text._ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj[_ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj]+0x90): undefined reference to `cv::Mat::Mat(int, int, int, void*, unsigned long)'
main.cpp:(.text._ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj[_ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj]+0xec): undefined reference to `cv::imencode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
main.cpp:(.text._ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj[_ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj]+0x114): undefined reference to `cpp_redis::client::client()'
main.cpp:(.text._ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj[_ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj]+0x164): undefined reference to `cpp_redis::client::connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::function<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, cpp_redis::connect_state)> const&, unsigned int, int, unsigned int)'
main.cpp:(.text._ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj[_ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj]+0x408): undefined reference to `cpp_redis::client::set(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
main.cpp:(.text._ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj[_ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj]+0x46c): undefined reference to `cpp_redis::client::sync_commit()'
main.cpp:(.text._ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj[_ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj]+0x4a0): undefined reference to `cpp_redis::client::~client()'
main.cpp:(.text._ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj[_ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj]+0x4a8): undefined reference to `cv::Mat::~Mat()'
main.cpp:(.text._ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj[_ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj]+0xa90): undefined reference to `cpp_redis::client::~client()'
main.cpp:(.text._ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj[_ZN21CameraCustomSimpleApp9frameGrabEP13dwImageObjectj]+0xa98): undefined reference to `cv::Mat::~Mat()'
collect2: error: ld returned 1 exit status
src/sensors/camera/camera/CMakeFiles/sample_camera.dir/build.make:130: recipe for target 'src/sensors/camera/camera/sample_camera' failed
make[2]: *** [src/sensors/camera/camera/sample_camera] Error 1
CMakeFiles/Makefile2:2246: recipe for target 'src/sensors/camera/camera/CMakeFiles/sample_camera.dir/all' failed
make[1]: *** [src/sensors/camera/camera/CMakeFiles/sample_camera.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

Attached is the complete error stack
error.txt (13.6 KB)
trace in error.txt file.

As the linker error is not resolved.
I’m attaching files in /usr/local/lib directory and output of “sudo ldconfig” command.

usr_local_lib.txt (17.7 KB)
ldconfig.txt (5.7 KB)

I’m able to understand the issue but could you please reconfirm and advice me with the right path of solution.

This may be a common issue encountered by OpenCV/CMake developers.
Please search if any solution on the internet.

Hi @VickNV ,

I tried with different configuration in CMakeLists.txt but it didn’t work.

Attaching the camera CMakeLists file.
CMakeLists.txt (1.8 KB)

Also, here is my code in main.cpp where the parameters to the Mat are (int, int, int, uint8_t * )
but the error is showing as undefined reference to `cv::Mat::Mat(int, int, int, void*, unsigned long)’

cv::Mat matImage = cv::Mat(imgCPU->prop.width, imgCPU->prop.height, CV_8UC3, imgCPU->data[0]);

I don’t have much experience with CMake. Any help would be highly appreciated.

Dear @VickNV ,

I’ve resolved the previous undefined reference errors by appropriately changing the CMakeLists.txt file of camera application.

StackOverflow: c++ - make error: undefined reference to cpp_redis::client::set(..) and cv::Mat::~Mat() - Stack Overflow

Attached here for future reference:
CMakeLists.txt (1.7 KB)

Now I’m facing the below error during make:
Error stack trace:

/usr/local/lib/libopencv_video.so.4.6.0: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status

Please help me resolve this error.

Good to hear that you solved the previous issue.

You may check if the library loaded by loader is in the right format as your executable.

I’m having different versions of libopencv_video.
Is the correct library being loaded for cross-compilation.

locate libopencv_video
/opt/opencv/release/lib/libopencv_video.so
/opt/opencv/release/lib/libopencv_video.so.4.6.0
/opt/opencv/release/lib/libopencv_video.so.406
/usr/lib/x86_64-linux-gnu/libopencv_video.a
/usr/lib/x86_64-linux-gnu/libopencv_video.so
/usr/lib/x86_64-linux-gnu/libopencv_video.so.3.2
/usr/lib/x86_64-linux-gnu/libopencv_video.so.3.2.0
/usr/local/lib/libopencv_video.so
/usr/local/lib/libopencv_video.so.4.6.0
/usr/local/lib/libopencv_video.so.406

Shall I use 3.2 version?

If it’s for cross-compilation, I think it should load ARM aarch64 libraries. You may use “file” command to check it.

Could you please specify which ARM aarch64 OpenCV version to install in my host-pc for cross-compilation along with the steps if possible.

Maybe you should refer to OpenCV: Cross compilation for ARM based Linux systems, or check OpenCV forums or communities.

Hi @VickNV,

Here are the OpenCV cross-compile steps I followed.

lidar@nvidia-drive:~/opencv_aarch64/opencv/platforms/linux/build_hardfp$ cmake -DCMAKE_TOOLCHAIN_FILE=../arm-gnueabi.toolchain.cmake ../../..
-- The CXX compiler identification is GNU 7.5.0
-- The C compiler identification is GNU 7.5.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
.............
...........
............
-- 
-- General configuration for OpenCV 4.6.0-pre =====================================
--   Version control:               4.5.5-440-g9da9e8244b-dirty
-- 
--   Platform:
--     Timestamp:                   2022-06-02T06:08:36Z
--     Host:                        Linux 5.4.0-113-generic x86_64
--     Target:                      Linux 1 arm
--     CMake:                       3.17.3
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               Release
-- 
--   CPU/HW features:
--     Baseline:
--       requested:                 DETECT
--       disabled:                  VFPV3 NEON
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ standard:                11
--     C++ Compiler:                /usr/bin/c++  (ver 7.5.0)
--     C++ flags (Release):         -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-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
--     C++ flags (Debug):           -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-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
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-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
--     C flags (Debug):             -fsigned-char -W -Wall -Wreturn-type -Waddress -Wsequence-point -Wformat -Wformat-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
--     Linker flags (Release):      -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined  
--     Linker flags (Debug):        -Wl,--gc-sections -Wl,--as-needed -Wl,--no-undefined  
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          dl m pthread rt
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo stitching ts video videoio
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 java python2 python3
--     Applications:                tests perf_tests apps
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   GUI:                           NONE
--     GTK+:                        NO
-- 
--   Media I/O: 
--     ZLib:                        zlib (ver 1.2.12)
--     JPEG:                        libjpeg-turbo (ver 2.1.2-62)
--     WEBP:                        build (ver encoder: 0x020f)
--     PNG:                         build (ver 1.6.37)
--     TIFF:                        build (ver 42 - 4.2.0)
--     JPEG 2000:                   build (ver 2.4.0)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
-- 
--   Video I/O:
--     DC1394:                      NO
--     FFMPEG:                      NO
--       avcodec:                   NO
--       avformat:                  NO
--       avutil:                    NO
--       swscale:                   NO
--       avresample:                NO
--     GStreamer:                   NO
--     v4l/v4l2:                    YES (linux/videodev2.h)
-- 
--   Parallel framework:            pthreads
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Lapack:                      NO
--     Custom HAL:                  NO
--     Protobuf:                    build (3.19.1)
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/lidar/opencv_aarch64/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python (for build):            /usr/bin/python2.7
-- 
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lidar/opencv_aarch64/opencv/platforms/linux/build_hardfp
lidar@nvidia-drive:~/opencv_aarch64/opencv/platforms/linux/build_hardfp$ sudo make -j32
[sudo] password for lidar: 
Scanning dependencies of target opencv_highgui_plugins
Scanning dependencies of target quirc
Scanning dependencies of target libopenjp2
Scanning dependencies of target zlib
Scanning dependencies of target ittnotify
Scanning dependencies of target libprotobuf
Scanning dependencies of target opencv_videoio_plugins
Scanning dependencies of target ade
Scanning dependencies of target libjpeg-turbo
Scanning dependencies of target libwebp
[  0%] Built target opencv_highgui_plugins
[  0%] Building C object 3rdparty/quirc/CMakeFiles/quirc.dir/src/quirc.c.o
[  0%] Building C object 3rdparty/quirc/CMakeFiles/quirc.dir/src/decode.c.o
[  0%] Building C object 3rdparty/quirc/CMakeFiles/quirc.dir/src/version_db.c.o
[  0%] Built target opencv_videoio_plugins
[  0%] Building C object 3rdparty/ittnotify/CMakeFiles/ittnotify.dir/src/ittnotify/jitprofiling.c.o
[  0%] Building C object 3rdparty/ittnotify/CMakeFiles/ittnotify.dir/src/ittnotify/ittnotify_static.c.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/compress.c.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/adler32.c.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/crc32.c.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/gzclose.c.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/deflate.c.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/gzread.c.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/gzlib.c.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/gzwrite.c.o
[  1%] Building CXX object CMakeFiles/ade.dir/3rdparty/ade/ade-0.1.1f/sources/ade/source/edge.cpp.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/infback.c.o
[  1%] Building CXX object CMakeFiles/ade.dir/3rdparty/ade/ade-0.1.1f/sources/ade/source/assert.cpp.o
[  1%] Building CXX object CMakeFiles/ade.dir/3rdparty/ade/ade-0.1.1f/sources/ade/source/alloc.cpp.o
[  1%] Building CXX object CMakeFiles/ade.dir/3rdparty/ade/ade-0.1.1f/sources/ade/source/execution_engine.cpp.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/inftrees.c.o
[  1%] Building CXX object CMakeFiles/ade.dir/3rdparty/ade/ade-0.1.1f/sources/ade/source/graph.cpp.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/inflate.c.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/trees.c.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/inffast.c.o
[  1%] Building CXX object CMakeFiles/ade.dir/3rdparty/ade/ade-0.1.1f/sources/ade/source/memory_descriptor.cpp.o
[  1%] Building C object 3rdparty/zlib/CMakeFiles/zlib.dir/zutil.c.o
.............................
....................................
........................................
[ 95%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/common/gapi_video_tests.cpp.o
[ 95%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/common/gapi_render_tests.cpp.o
[ 95%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/cpu/gapi_core_tests_fluid.cpp.o
[ 95%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/common/gapi_operators_tests.cpp.o
[ 95%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/cpu/gapi_imgproc_tests_cpu.cpp.o
[ 95%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/cpu/gapi_ocv_stateful_kernel_tests.cpp.o
[ 95%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/cpu/gapi_imgproc_tests_fluid.cpp.o
[ 95%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/cpu/gapi_operators_tests_cpu.cpp.o
[ 95%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/cpu/gapi_operators_tests_fluid.cpp.o
[ 95%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/cpu/gapi_stereo_tests_cpu.cpp.o
[ 95%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/executor/gtbbexecutor_internal_tests.cpp.o
[ 95%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/cpu/gapi_video_tests_cpu.cpp.o
[ 95%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_array_tests.cpp.o
[ 95%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_async_test.cpp.o
[ 96%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_basic_hetero_tests.cpp.o
[ 96%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_compile_args_tests.cpp.o
[ 96%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_desc_tests.cpp.o
[ 96%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_fluid_parallel_rois_test.cpp.o
[ 96%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_fluid_resize_test.cpp.o
[ 96%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_fluid_roi_test.cpp.o
[ 96%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_fluid_test.cpp.o
[ 96%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_fluid_test_kernels.cpp.o
[ 96%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_frame_tests.cpp.o
[ 96%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_gcompiled_tests.cpp.o
[ 96%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_gcomputation_tests.cpp.o
[ 96%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_gpu_test.cpp.o
[ 96%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_graph_meta_tests.cpp.o
[ 96%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_kernel_tests.cpp.o
[ 96%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_opaque_tests.cpp.o
[ 97%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_plaidml_pipelines.cpp.o
[ 97%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_planar_test.cpp.o
[ 97%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_sample_pipelines.cpp.o
[ 97%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_scalar_tests.cpp.o
[ 97%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_smoke_test.cpp.o
[ 97%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_transform_tests.cpp.o
[ 97%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_typed_tests.cpp.o
[ 97%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gapi_util_tests.cpp.o
[ 97%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gpu/gapi_core_tests_gpu.cpp.o
[ 97%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gpu/gapi_imgproc_tests_gpu.cpp.o
[ 97%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/gpu/gapi_operators_tests_gpu.cpp.o
[ 97%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/infer/gapi_infer_ie_test.cpp.o
[ 97%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/infer/gapi_infer_onnx_test.cpp.o
[ 97%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/infer/gapi_infer_tests.cpp.o
[ 97%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_int_backend_tests.cpp.o
[ 98%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_int_dynamic_graph.cpp.o
[ 98%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_int_executor_tests.cpp.o
[ 98%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_int_garg_test.cpp.o
[ 98%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_int_gmetaarg_test.cpp.o
[ 98%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_int_gmodel_builder_test.cpp.o
[ 98%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_int_island_fusion_tests.cpp.o
[ 98%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_int_pattern_matching_test.cpp.o
[ 98%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_int_island_tests.cpp.o
[ 98%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_int_perform_substitution_test.cpp.o
[ 98%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_int_proto_tests.cpp.o
[ 98%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_int_recompilation_test.cpp.o
[ 98%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_int_vectorref_test.cpp.o
[ 98%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_transactions_test.cpp.o
[ 98%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/oak/gapi_tests_oak.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/own/conc_queue_tests.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/own/gapi_types_tests.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/own/last_written_value_tests.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/own/mat_tests.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/own/scalar_tests.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/render/ftp_render_test.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/render/gapi_render_tests_ocv.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/rmat/rmat_integration_tests.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/rmat/rmat_tests.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/rmat/rmat_view_tests.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/s11n/gapi_s11n_tests.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/s11n/gapi_sample_pipelines_s11n.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/streaming/gapi_gstreamer_pipeline_facade_int_tests.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/streaming/gapi_gstreamersource_tests.cpp.o
[ 99%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/streaming/gapi_streaming_sync_tests.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/streaming/gapi_streaming_tests.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/streaming/gapi_streaming_utils_test.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/streaming/gapi_streaming_vpl_core_test.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/streaming/gapi_streaming_vpl_data_provider.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/streaming/gapi_streaming_vpl_device_selector.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/streaming/gapi_streaming_vpp_preproc_test.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/test_main.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/util/any_tests.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/util/optional_tests.cpp.o
[100%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/util/variant_tests.cpp.o
[100%] Linking CXX executable ../../bin/opencv_perf_gapi
[100%] Built target opencv_perf_gapi
[100%] Linking CXX executable ../../bin/opencv_test_gapi
[100%] Built target opencv_test_gapi
lidar@nvidia-drive:~/opencv_aarch64/opencv/platforms/linux/build_hardfp$ 

After successful MAKE I included all cross-compiled specific libraries in CMakeLists.txt for CAMERA application as shown below:

target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBRARIES}
"/home/lidar/opencv_aarch64/opencv/platforms/linux/build_hardfp/lib/libopencv_core.so.406"

After doing these steps I cross-compiled again but during MAKE I’m again facing same error:

/build_hardfp/lib/libopencv_core.so.406: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status

I’m unable to understand how to proceed forward.

Please assign a specific person who has previously cross-compiled OpenCV dependency in driveworks.

Have you checked its file type with “file” command?

lidar@nvidia-drive:~/Documents/Nvidia_Drive/buildCrossCompile$ file /home/lidar/opencv_aarch64/opencv/platforms/linux/build_hardfp/lib/libopencv_core.so.4.6.0
/home/lidar/opencv_aarch64/opencv/platforms/linux/build_hardfp/lib/libopencv_core.so.4.6.0: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=31e88a4d997d84126dd6bc36cfd7e32906b8b1d8, not stripped

All of the libraries are of x86-64 version.

x86-64 version cannot be used for cross-compiling. That’s why I suggested you check if there is any information in OpenCV forums or communities.