cross-compile linking opencv libraries failed

My source code is as below:

#include <opencv2/highgui.hpp>
#include <opencv2/core.hpp>

int mian(int argc, char* argv[])
{
  argc = argc;
  cv::Mat a = cv::imread(argv[1]);
  cv::imshow("test", a);
  cv::waitKey(10);
  return 0;
}

My CMakeLists.txt is as below

# Copyright (c) 2016, NVIDIA CORPORATION.  All rights reserved.

project(opencv C CXX)

#-------------------------------------------------------------------------------
# Project files
#-------------------------------------------------------------------------------
set(PUBLIC_DOCS
    README.md
)

set(SOURCES
    main.cpp
)

find_package(OpenCV REQUIRED PATHS /home/hero/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_b/usr/local)
include_directories(${Opencv_INCLUDE_DIR})

set(LIBRARIES
    samples_framework
    ${Driveworks_LIBRARIES}
    ${OpenCV_LIBRARIES}
    )

#-------------------------------------------------------------------------------
# Final target
#-------------------------------------------------------------------------------
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} ${LIBRARIES})
set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER "Samples")

# ------------------------------------------------------------------------------
# Install target
# ------------------------------------------------------------------------------
sdk_add_sample(${PROJECT_NAME})

When I try to do make, it endup with below errors.

/home/hero/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/7.3.1/../../../../a$
rch64-linux-gnu/bin/ld: warning: libEGL.so.1, needed by /home/hero/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs/usr/local/driveworks-2.2/tar$
ets/aarch64-Linux/lib/libnvinfer.so.5, not found (try using -rpath or -rpath-link)
/home/hero/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/../aarch64-linux-gnu/libc/usr/lib/crt1.o: In fun$
tion `_start':
/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/snapshots/glibc.git~release~2.25~master/csu/../sysdeps/aarch64/star$
.S:86: undefined reference to `main'
/home/hero/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_b/lib/aarch64-linux-gnu/libc-2.27.so: undefined reference to `_dl_exception_create@G$
IBC_PRIVATE'
/home/hero/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_b/usr/local/lib/libopencv_imgproc.so.3.4.2: undefined reference to `expf@GLIBC_2.27'
/home/hero/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_b/lib/aarch64-linux-gnu/libc-2.27.so: undefined reference to `__tunable_get_val@GLIB$_PRIVATE'
/home/hero/nvidia/nvidia_sdk/DRIVE_Software_10.0_Linux_OS_E3550/DRIVEOS/drive-t186ref-linux/targetfs_b/usr/local/lib/libopencv_core.so.3.4.2: undefined reference to `logf@GLIBC_2.27'
collect2: error: ld returned 1 exit status
src/opencv/CMakeFiles/opencv.dir/build.make:124: recipe for target 'src/opencv/opencv' failed
make[2]: *** [src/opencv/opencv] Error 1
CMakeFiles/Makefile2:421: recipe for target 'src/opencv/CMakeFiles/opencv.dir/all' failed
make[1]: *** [src/opencv/CMakeFiles/opencv.dir/all] Error 2
Makefile:129: recipe for target 'all' failed

Opencv libraries are cross-compiled and installed to targetfs/usr/local.I can find libc.so and libc-2.27.so in targetfs/usr/lib/aarch64-linux-gnu/, compiling opencv i follow https://devtalk.nvidia.com/default/topic/1044512/general/opencv-unable-to-stop-the-stream-inappropriate-ioctl-for-device/?offset=2#

Dear zhengxiaofeng333,
We are still checking on steps to cross compile opencv for DRIVE AGX. But, May I know what functionalities are you looking to use from openCV? Do you see any gap in our Driveworks?

Thanks for your reponse.
Our project firstly build for tx2, and transplant to pegasus. Most of usage is using cv::Mat as a container of images, and using some basic function such as cv::resize cv::imshow. It will take a long time to drop opencv.So what is your suggestion then? And is it possable to cross compile opencv for agx?

Dear zhengxiaofeng333,
We provide image resizing APIs in Driveworks(Please see https://docs.nvidia.com/driveworks/dwx_imagetransformation.html) which is optimized for our platfrom. OpenCV is not optimzed for DRIVE AGX platform. We recommend using Driveworks if possible. Let us know if you see any gaps or needed functionalities

Thank you! By the way, does protobuf support cross compile?

and glog.

Hi zhengxiaofeng333,
protobuf and glog is not something that we are maintaining in our software stack.
I’d suggest you reach out to Google communities for support for cross compiling to ARM.

Dear zhengxiaofeng333,
We have posted OpenCV compliation steps at https://devtalk.nvidia.com/default/topic/1071460/faq/opencv-compile-opencv-4-1-1-on-drive-software-10-0/. Please check and let us know if you have any issues.
Note that OpenCV is not optimized for DRIVE AGX platform. We recommend to use Driveworks to make use of available HW accelerators efficiently.

Dear zhengxiaofeng333,

Please use your business email ID in all your future correspondence. Also, please advise if this issue can be closed.

Thanks!