cmake DeepStream nvgstiva-app_sources

Your DeepStream SDK samples use a Makefile to build.
But my IDE Clion from JetBrains forces me to use cmake as a build system.

I need an IDE that lets me navigate references.

The only IDE ive been able to get working on the TX2 is CLion ( debugger still doesnt work )

I dont want to try another IDE. I just want to finish this cmake that mimics your Makefile.

But i keep getting this error…
CMakeFiles/nvstgiva-app3.dir/src/nvgstiva_app.c.o: In function bus_callback': /home/nvidia/nvgstiva-app_sources/nvgstiva-app3/src/nvgstiva_app.c:89: undefined reference to NVIVA_APP’

i tried this but doesnt work.
add_executable(nvstgiva-app3 {nvstgiva-app3_SOURCES} {nvstgiva-app3_INCLUDES} )
target_link_libraries(nvstgiva-app3 ${nvstgiva-app3_LIBRARIES} -lgstnvivameta -lnvid_mapper)

set_target_properties(nvstgiva-app3 PROPERTIES LINK_FLAGS “-lgstnvivameta -lnvid_mapper”)

Hi,

Here is a CMakeLists.txt example for your reference:
https://devtalk.nvidia.com/default/topic/1026656/jetson-tx2/compile-cuda-program-with-dynamic-parallelism/post/5221874/#5221874

Ex.

...
include_directories(
    /add/include/path/here
)
link_directories(
    /add/link/path/here
)
...
target_link_libraries(
    -lgstnvivameta -lnvid_mapper
)

Thanks.

1 Like

i tried that style but it didnt work. i ended up taking out the target_link libraries and this worked…

cmake_minimum_required(VERSION 3.5)
project(nvgstiva_app5)

set(CMAKE_CXX_STANDARD 11)

find_package(PkgConfig)

#pkg_check_modules(GST REQUIRED gstreamer-1.0>=1.4)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
pkg_check_modules(GSTREAMER-APP REQUIRED gstreamer-app-1.0)
pkg_check_modules(GSTREAMER-AUDIO REQUIRED gstreamer-audio-1.0)
pkg_check_modules(GSTREAMER-PBUTILS REQUIRED gstreamer-pbutils-1.0)
pkg_check_modules(GSTREAMER-FFT REQUIRED gstreamer-fft-1.0)

include_directories(
{GLIB_INCLUDE_DIRS} includes {GSTREAMER_INCLUDE_DIRS}
{GSTREAMER-APP_INCLUDE_DIRS} {GSTREAMER-AUDIO_INCLUDE_DIRS}
{GSTREAMER-PBUTILS_INCLUDE_DIRS} {GSTREAMER-FFT_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
)

link_directories(
{GLIB_LIBRARY_DIRS} {GSTREAMER_LIBRARY_DIRS}
{GSTREAMER-APP_LIBRARY_DIRS} {GSTREAMER-AUDIO_LIBRARY_DIRS}
{GSTREAMER-PBUTILS_LIBRARY_DIRS} {GSTREAMER-FFT_LIBRARY_DIRS}
)

link_libraries(
gstnvivameta
nvid_mapper
{GSTREAMER_LIBRARIES} {GSTREAMER-APP_LIBRARIES}
{GSTREAMER-AUDIO_LIBRARIES} {GSTREAMER-PBUTILS_LIBRARIES}
${GSTREAMER-FFT_LIBRARIES}

)
add_executable(nvgstiva_app5
includes/gstnvivameta_api.h
includes/nv_object_colors.h
includes/nvbuf_utils.h
includes/nvgstiva_app.h
includes/nvgstiva_color_detector.h
includes/nvgstiva_colors.h
includes/nvgstiva_common.h
includes/nvgstiva_config.h
includes/nvgstiva_dsexample.h
includes/nvgstiva_face_detector.h
includes/nvgstiva_gie.h
includes/nvgstiva_metadata_pool.h
includes/nvgstiva_osd.h
includes/nvgstiva_perf.h
includes/nvgstiva_primary_gie.h
includes/nvgstiva_secondary_gie.h
includes/nvgstiva_sinks.h
includes/nvgstiva_sources.h
includes/nvgstiva_split_bin.h
includes/nvgstiva_tracker.h
includes/nvgstiva_txrx.h
includes/nvid_mapper.h
includes/nvosd.h
includes/NvTxRx.h
src/nvgstiva_app.c
src/nvgstiva_color_detector_bin.c
src/nvgstiva_common.c
src/nvgstiva_config_file_parser.c
src/nvgstiva_dsexample.c
src/nvgstiva_face_detector_bin.c
src/nvgstiva_metadata_pool.c
src/nvgstiva_osd_bin.c
src/nvgstiva_perf.c
src/nvgstiva_primary_gie_bin.c
src/nvgstiva_secondary_gie_bin.c
src/nvgstiva_sink_bin.c
src/nvgstiva_source_bin.c
src/nvgstiva_split_bin.c
src/nvgstiva_tracker_bin.c
nvgstiva_app_main.c)

but now im having another problem with the more complicated
gst_dsexample_sources

/usr/bin/cmake --build /home/nvidia/gst-dsexample_sources2/cmake-build-debug --target gst_dsexample_sources2 – -j 2
[ 33%] Building C object CMakeFiles/gst_dsexample_sources2.dir/dsexample_lib/dsexample_lib.c.o
[ 66%] Building CXX object CMakeFiles/gst_dsexample_sources2.dir/gstdsexample.cpp.o
[100%] Linking CXX executable gst_dsexample_sources2
/usr/lib/gcc/aarch64-linux-gnu/5/…/…/…/aarch64-linux-gnu/crt1.o: In function _start': (.text+0x30): undefined reference to main’
collect2: error: ld returned 1 exit status

i got this one to build but i dont know if it right…

heres my cmake
cmake_minimum_required(VERSION 3.5)
project(gst_dsexample_sources2)
set(CMAKE_CXX_FLAGS “-Wall -g”)
set(CMAKE_CXX_STANDARD 11)

find_package(PkgConfig)

find_package(OpenCV REQUIRED)
#pkg_check_modules( OpenCV REQUIRED opencv)
#pkg_check_modules(GST REQUIRED gstreamer-1.0>=1.4)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
pkg_check_modules(GSTREAMER-APP REQUIRED gstreamer-app-1.0)
pkg_check_modules(GSTREAMER-AUDIO REQUIRED gstreamer-audio-1.0)
pkg_check_modules(GSTREAMER-PBUTILS REQUIRED gstreamer-pbutils-1.0)
pkg_check_modules(GSTREAMER-FFT REQUIRED gstreamer-fft-1.0)
pkg_check_modules(GSTREAMER-VIDEO REQUIRED gstreamer-video-1.0)
pkg_check_modules(GSTREAMER-BASE REQUIRED gstreamer-base-1.0)

include_directories(
.
…/nvgstiva-app_sources/nvgstiva-app/includes
dsexample_lib
{GSTREAMER_INCLUDE_DIRS} {GSTREAMER-APP_INCLUDE_DIRS}
{GSTREAMER-AUDIO_INCLUDE_DIRS} {GSTREAMER-PBUTILS_INCLUDE_DIRS}
{GSTREAMER-FFT_INCLUDE_DIRS} {GSTREAMER-VIDEO_INCLUDE_DIRS}
{GSTREAMER-BASE_INCLUDE_DIRS} {CMAKE_CURRENT_SOURCE_DIR}
)

link_directories(
{CMAKE_CURRENT_SOURCE_DIR} /usr/lib/aarch64-linux-gnu/tegra ../nvgstiva-app_sources/nvgstiva-app/src dsexample_lib {GSTREAMER_LIBRARY_DIRS}
{GSTREAMER-APP_LIBRARY_DIRS} {GSTREAMER-AUDIO_LIBRARY_DIRS}
{GSTREAMER-PBUTILS_LIBRARY_DIRS} {GSTREAMER-FFT_LIBRARY_DIRS}
{GSTREAMER-VIDEO_LIBRARY_DIRS} {GSTREAMER-BASE_LIBRARY_DIRS}
)

link_libraries(
dsexample
nvbuf_utils
gstnvivameta
EGL
{GSTREAMER_LIBRARIES} {GSTREAMER-APP_LIBRARIES}
{GSTREAMER-AUDIO_LIBRARIES} {GSTREAMER-PBUTILS_LIBRARIES}
{GSTREAMER-FFT_LIBRARIES} {GSTREAMER-VIDEO_LIBRARIES}
{GSTREAMER-BASE_LIBRARIES} {OpenCV_LIBS}

)
set(CMAKE_C_FLAGS “${CMAKE_C_FLAGS} -fPIC”)

set (CMAKE_SHARED_LINKER_FLAGS “${CMAKE_SHARED_LINKER_FLAGS} -L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils -lgstnvivameta -Wl,-no-undefined -L dsexample_lib -ldsexample -lEGL”)

add_library(gst_dsexample_sources2
dsexample_lib/dsexample_lib.c
dsexample_lib/dsexample_lib.h
gstdsexample.cpp
gstdsexample.h)

ok i got ds example to build
so now how do i call it from a pipeline
how do i integrate it into app?

cmake_minimum_required(VERSION 3.5)
project(gst_dsexample_sources2)
set(CMAKE_CXX_FLAGS “-Wall -g”)
set(CMAKE_CXX_STANDARD 11)

find_package(PkgConfig)

find_package(OpenCV REQUIRED)
#pkg_check_modules( OpenCV REQUIRED opencv)
#pkg_check_modules(GST REQUIRED gstreamer-1.0>=1.4)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
pkg_check_modules(GSTREAMER-APP REQUIRED gstreamer-app-1.0)
pkg_check_modules(GSTREAMER-AUDIO REQUIRED gstreamer-audio-1.0)
pkg_check_modules(GSTREAMER-PBUTILS REQUIRED gstreamer-pbutils-1.0)
pkg_check_modules(GSTREAMER-FFT REQUIRED gstreamer-fft-1.0)
pkg_check_modules(GSTREAMER-VIDEO REQUIRED gstreamer-video-1.0)
pkg_check_modules(GSTREAMER-BASE REQUIRED gstreamer-base-1.0)

include_directories(
.
…/nvgstiva-app_sources/nvgstiva-app/includes
dsexample_lib
{GSTREAMER_INCLUDE_DIRS} {GSTREAMER-APP_INCLUDE_DIRS}
{GSTREAMER-AUDIO_INCLUDE_DIRS} {GSTREAMER-PBUTILS_INCLUDE_DIRS}
{GSTREAMER-FFT_INCLUDE_DIRS} {GSTREAMER-VIDEO_INCLUDE_DIRS}
{GSTREAMER-BASE_INCLUDE_DIRS} {CMAKE_CURRENT_SOURCE_DIR}
)

link_directories(
{CMAKE_CURRENT_SOURCE_DIR} /usr/lib/aarch64-linux-gnu/tegra ../nvgstiva-app_sources/nvgstiva-app/src dsexample_lib {GSTREAMER_LIBRARY_DIRS}
{GSTREAMER-APP_LIBRARY_DIRS} {GSTREAMER-AUDIO_LIBRARY_DIRS}
{GSTREAMER-PBUTILS_LIBRARY_DIRS} {GSTREAMER-FFT_LIBRARY_DIRS}
{GSTREAMER-VIDEO_LIBRARY_DIRS} {GSTREAMER-BASE_LIBRARY_DIRS}
)

link_libraries(
dsexample
nvbuf_utils
gstnvivameta
EGL
{GSTREAMER_LIBRARIES} {GSTREAMER-APP_LIBRARIES}
{GSTREAMER-AUDIO_LIBRARIES} {GSTREAMER-PBUTILS_LIBRARIES}
{GSTREAMER-FFT_LIBRARIES} {GSTREAMER-VIDEO_LIBRARIES}
{GSTREAMER-BASE_LIBRARIES} {OpenCV_LIBS}

)
set(CMAKE_C_FLAGS “${CMAKE_C_FLAGS} -fPIC”)

set (CMAKE_SHARED_LINKER_FLAGS “${CMAKE_SHARED_LINKER_FLAGS} -L/usr/lib/aarch64-linux-gnu/tegra -lnvbuf_utils -lgstnvivameta -Wl,-no-undefined -L dsexample_lib -ldsexample -lEGL”)

add_library(gst_dsexample_sources2
dsexample_lib/dsexample_lib.c
dsexample_lib/dsexample_lib.h
gstdsexample.cpp
gstdsexample.h)

We don’t have much experience in this. Other users may share experience/guidance about Makefile programming.

nVidia guys,
How are the you building and debugging your samples/apps? What IDE are you using?
Is it all command line stuff?
The thing I am missing is real world guidance on actually incorporating DS SDK into an application - it is an SDK after all. It’s not about being able to build the sample apps.

Hi,
By default we would suggest users modify config files and simply run 'deepstream-app -c YOUR_CONFIG_FILE.
IF the default code does not fit your usecase and you need to do customization, we would suggest build it on device(Jetson platforms or dGPU) directly.

Hi,

Thank you for your response.
Since DS is an SDK I would not expect to just run prebuilt examples as a typical use case.
Let’s assume I want to build it on the Jetson directly - again - my question is why is there no CMAKE config officially provided by nVidia? Why use the old GNU MAKE that is difficult to support??
Maybe I’m missing something, but it seems this is as difficult as it can be, instead of simplifying it with a nice CMAKE that anyone can use with their favorite tools/IDE.

Personally, I’m coming from a Windows background and I find the Linux tools sadly lacking in simplicity. Visual Studio Code is the closest that works on Linux as well, and there is decent support for CMAKE by an extension. Please provide one that can be used as a starting point for new projects based on the DS SDK.

Pavel

Hi,
In current releases, the samples are released with Makefile. We will evaluate the request of supporting CMAKE in future releases.

Can I get a straight response - what IDE are you using for building and debugging?
Especially debugging