Hello, I have the same problem. I guess the problem is because libjpeg.so and libnvjpeg.so exist together. I have both NVJPEG and OpenCV in my program, NVJPEG rely on libnvjpeg.so, OpenCV rely on libjpeg.so.
When doing TARGET_LINK_LIBRARIES, this error will occur if libjpeg.so is in front, and if libnvjpeg.so is in front, the segment fault will occur.
How can I solve this problem?
Here is my CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project(deepstream-xlaf)
set(project_name deepstream-xlaf)
add_compile_options(-O2 -pthread -Wall)
set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -std=c++11 -Ofast -Wfatal-errors -D_MWAITXINTRIN_H_INCLUDED”)
INCLUDE_DIRECTORIES(/usr/include)
INCLUDE_DIRECTORIES(/usr/include/glib-2.0)
INCLUDE_DIRECTORIES(/usr/include/json-glib-1.0)
INCLUDE_DIRECTORIES(/usr/include/gstreamer-1.0)
INCLUDE_DIRECTORIES(/usr/lib/aarch64-linux-gnu/glib-2.0/include)
LINK_DIRECTORIES(/usr/lib/aarch64-linux-gnu)
set(sys_libs pthread v4l2 dl m X11 json-glib-1.0 gobject-2.0 glib-2.0 jpeg)
set(gst_libs gstreamer-1.0 gstvideo-1.0 gstrtspserver-1.0)
LINK_DIRECTORIES(/usr/lib/aarch64-linux-gnu/tegra)
set(nv_libs nvbuf_utils nvbufsurface nvv4l2 nvjpeg)
INCLUDE_DIRECTORIES(/opt/nvidia/deepstream/deepstream-5.0/sources/includes)
INCLUDE_DIRECTORIES(/opt/nvidia/deepstream/deepstream-5.0/sources/apps/apps-common/includes)
LINK_DIRECTORIES(/opt/nvidia/deepstream/deepstream-5.0/lib)
set(nvds_libs nvds_utils nvds_meta nvds_msgbroker nvdsgst_meta nvdsgst_helper nvdsgst_smartrecord)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/deepstream/common/include)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/jetson_multimedia/include)
aux_source_directory(${PROJECT_SOURCE_DIR} src_list)
aux_source_directory(${PROJECT_SOURCE_DIR}/jetson_multimedia/src jpg_list)
aux_source_directory(${PROJECT_SOURCE_DIR}/deepstream/common/src dsc_list)
INCLUDE_DIRECTORIES(/usr/local/cuda/include)
LINK_DIRECTORIES(/usr/local/cuda/lib64)
SET(cuda_libs cudart)
INCLUDE_DIRECTORIES(/usr/local/include/opencv4)
LINK_DIRECTORIES(/usr/local/lib)
set(ocv_libs opencv_core opencv_imgproc opencv_highgui opencv_imgcodecs)
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
add_executable(${project_name} ${src_list} ${jpg_list} ${dsc_list})
target_link_libraries(${project_name} ${sys_libs})
target_link_libraries(${project_name} ${gst_libs})
target_link_libraries(${project_name} ${nv_libs})
target_link_libraries(${project_name} ${nvds_libs})
target_link_libraries(${project_name} ${cuda_libs})
target_link_libraries(${project_name} ${ocv_libs})