How to compile driveworks sample source codes including opencv?

Hi,
We’re trying to compile a modified source codes of drivenet sample codes including opencv library.
We’ve successfully installed opencv 3.4.0 and now facing problems compiling the codes
that includes it.
Here’s what we have tried:
1.Modifying CMakesLists.txt under /home/kimna/Desktop/taewook/project/driveworks-0.6/ as below.
I’ve put #modified at the end of the modified/added line. please find them.

Copyright © 2016, NVIDIA CORPORATION. All rights reserved.

cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)

#-------------------------------------------------------------------------------

Set basic configurations

#-------------------------------------------------------------------------------
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(SamplesSetBuildType) # Set the build type before project is created

set(SDK_SOURCE_DIR {CMAKE_CURRENT_SOURCE_DIR}) set(SDK_BINARY_DIR {CMAKE_CURRENT_BINARY_DIR})

#-------------------------------------------------------------------------------

Root project

#-------------------------------------------------------------------------------
project(DriveworksSDK-Samples C CXX)

#-------------------------------------------------------------------------------

System packages

#-------------------------------------------------------------------------------
find_package(CUDA REQUIRED)
find_package(Threads REQUIRED)
find_package(TensorRT REQUIRED)
find_package(CuDNN REQUIRED)
find_package(OpenCV 3 REQUIRED) #modified
#-------------------------------------------------------------------------------

Basic configuration

#-------------------------------------------------------------------------------
include(ArchConfiguration)
include(CommonConfiguration)
include(SamplesConfiguration)
include(Samples3rdparty)

include(SamplesInstallConfiguration)
include(ExpandDependencyTree)
include(IncludeTargetDirectories)
include(UploadVibrante)
set(SDK_BINARY_DIR ${CMAKE_BINARY_DIR})

#-------------------------------------------------------------------------------

Driveworks SDK

#-------------------------------------------------------------------------------
find_package(Driveworks REQUIRED)
include_directories({Driveworks_INCLUDE_DIR}) include_directories( {OpenCV_INCLUDE_DIRS} ) #modified
list(APPEND Driveworks_LIBRARIES {CUDA_LIBRARIES} {CUDA_cublas_LIBRARY})

if(LINUX)
list(APPEND Driveworks_LIBRARIES {CMAKE_THREAD_LIBS_INIT} dl rt) elseif(VIBRANTE) list(APPEND Driveworks_LIBRARIES {vibrante_LIBRARIES} {vibrante_Xlibs_LIBRARIES} nvmedia {EGL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif()

#-------------------------------------------------------------------------------

Samples

#-------------------------------------------------------------------------------
if(CMAKE_CROSSCOMPILING)
set(DRIVEWORKS_DATAPATH “…/data”)


the rest is not modified

[b]

2.cmake command on terminal[/b]
No errors occurred. I’m reporting the command that I used and results below.

cmake -DCMAKE_BUILD_TYPE=Release \

  -DCMAKE_TOOLCHAIN_FILE=/home/kimna/Desktop/taewook/project/driveworks-0.6/samples/cmake/Toolchain-V4L.cmake \
  -DVIBRANTE_PDK:STRING=/home/kimna/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux \
   /home/kimna/Desktop/taewook/project/driveworks-0.6/samples

– VIBRANTE_PDK = /home/kimna/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux
– Vibrante version 5.0.5.0
– VIBRANTE_PDK = /home/kimna/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux
– Vibrante version 5.0.5.0
– The C compiler identification is GNU 4.9.2
– The CXX compiler identification is GNU 4.9.2
– Check for working C compiler: /home/kimna/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux/…/toolchains/tegra-4.9-nv/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-gcc
– Check for working C compiler: /home/kimna/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux/…/toolchains/tegra-4.9-nv/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-gcc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Check for working CXX compiler: /home/kimna/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux/…/toolchains/tegra-4.9-nv/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-g++
– Check for working CXX compiler: /home/kimna/NVIDIA/Drive/5050bL_SDK/DriveSDK/drive-t186ref-linux/…/toolchains/tegra-4.9-nv/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-g++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Found TensorRT:
– - Includes: /usr/local/nvidia/tensorrt/targets/aarch64-linux-gnu/include
– - Libraries: /usr/local/nvidia/tensorrt/targets/aarch64-linux-gnu/lib/libnvinfer.so;/usr/local/nvidia/tensorrt/targets/aarch64-linux-gnu/lib/libnvcaffe_parser.so
– Found libcudnn:
– - Includes: /usr/local/cuda-9.0/targets/aarch64-linux/include
– - Libraries: /usr/local/cuda-9.0/targets/aarch64-linux/lib/libcudnn.so
– Cross Compiling for Vibrante
– VIBRANTE_PDK_BRANCH = 5.0.5.0
– Found vibrante lib: /home/kimna/Desktop/taewook/project/driveworks-0.6/samples/3rdparty/linux-aarch64/vibrante/lib/libudev.so
– Found vibrante lib: /home/kimna/Desktop/taewook/project/driveworks-0.6/samples/3rdparty/linux-aarch64/vibrante/lib/libusb-1.0.so
– Found vibrante_Xlib: /home/kimna/Desktop/taewook/project/driveworks-0.6/samples/3rdparty/linux-aarch64/vibrante_Xlibs/lib/libXrandr.so
– Found vibrante_Xlib: /home/kimna/Desktop/taewook/project/driveworks-0.6/samples/3rdparty/linux-aarch64/vibrante_Xlibs/lib/libXinerama.so
– Found vibrante_Xlib: /home/kimna/Desktop/taewook/project/driveworks-0.6/samples/3rdparty/linux-aarch64/vibrante_Xlibs/lib/libXi.so
– Found vibrante_Xlib: /home/kimna/Desktop/taewook/project/driveworks-0.6/samples/3rdparty/linux-aarch64/vibrante_Xlibs/lib/libXcursor.so
– Driveworks Samples install dir: /home/kimna/Desktop/taewook/project/driveworks-0.6/build/install
– Cross Compiling for Vibrante
– Found Driveworks
– Configuring done
– Generating done
– Build files have been written to: /home/kimna/Desktop/taewook/project/driveworks-0.6/build

3. make command on the terminal
The error occurred here. The result is as below,
Scanning dependencies of target update_cuda_deps
[ 1%] Dependencies for /home/kimna/Desktop/taewook/project/driveworks-0.6/build/src/image/image_common/CMakeFiles/dw_samples_image_common.dir//gen_utils.cu.o.depend.stamp
cc1plus: error: include location “/usr/local/include” is unsafe for cross-compilation [-Werror=poison-system-directories]
cc1plus: error: include location “/usr/local/include/opencv” is unsafe for cross-compilation [-Werror=poison-system-directories]
cc1plus: all warnings being treated as errors
CMake Error at gen_utils.cu.o_deps.cmake:196 (message):
Error generating
/home/kimna/Desktop/taewook/project/driveworks-0.6/build/src/image/image_common/CMakeFiles/dw_samples_image_common.dir//gen_utils.cu.o.NVCC-depend

CMakeFiles/update_cuda_deps.dir/build.make:212: recipe for target ‘src/image/image_common/CMakeFiles/dw_samples_image_common.dir/gen_utils.cu.o.depend.stamp’ failed
make[2]: *** [src/image/image_common/CMakeFiles/dw_samples_image_common.dir/gen_utils.cu.o.depend.stamp] Error 1
CMakeFiles/Makefile2:99: recipe for target ‘CMakeFiles/update_cuda_deps.dir/all’ failed
make[1]: *** [CMakeFiles/update_cuda_deps.dir/all] Error 2
Makefile:129: recipe for target ‘all’ failed
make: *** [all] Error 2

Thanks,

Dear taewook101,

Could you please refer to below link for the topic? Thanks.

https://devtalk.nvidia.com/default/topic/1044512/general/opencv-unable-to-stop-the-stream-inappropriate-ioctl-for-device/

Dear SteveNV,
Thank you for the reply
The link is about how to install opencv via cross-compiling, but I’ve successfully install opencv.
Could you please let me know how to compile Driveworks sample source that uses opencv libraries?
I’m using pdk 5.0.5 by the way.
Thanks

Dear taewook101,

Could you please upgrade the PDK and DW? Because you’re using an older DW version.
And then please refer to the link I provided for your topic, we already verified this work without a problem. Thanks.