jetson-inference/utils cmake question

I’m new to cmake, so I’m wondering what i’m doing wrong here trying to use jetson-utils and jetson-inference in a test project. Both are installed on the system, Cmake generates the makefiles and seems to know where to find the libraries, but it won’t link. I am assuredly doing something wrong here.

Hi mdegans, if you run “make VERBOSE=1”, do you see -ljetson-utils on the link line? If not, you might want to explicitly state jetson-utils instead of jetson-utils_LIBRARIES variable.

Also you might want to try changing “add_executable()” to “cuda_add_executable()” and see if that makes any difference.

Nope. Everything else seems to be there, however.

/usr/bin/c++     CMakeFiles/birbrain.dir/main.cpp.o  -o birbrain -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0 -ljsoncpp /usr/local/cuda/lib64/libcudart_static.a -lpthread -ldl /usr/lib/aarch64-linux-gnu/librt.so

I changed the bottom to this:

...
target_link_libraries(${PROJECT_NAME}
    jetson-inference
    jetson-utils
    ${GSTREAMER_LIBRARIES}
    ${JSONCPP_LIBRARIES}
    ${CUDA_LIBRARIES}
)

And it works! Thank you so much!

It didn’t seem to matter here, but it’s a neat macro, so i edited out the manual CUDA stuff and it works in lieu… for anybody curious, the final cmakelists looks like:

project(birbrain)
cmake_minimum_required(VERSION 3.10.1)
set(CMAKE_CXX_STANDARD 17)

find_package(jetson-utils REQUIRED)
find_package(jetson-inference REQUIRED)
find_package(CUDA REQUIRED)

find_package(PkgConfig REQUIRED)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0 glib-2.0)
pkg_check_modules(JSONCPP REQUIRED jsoncpp)

include_directories(
    ${jetson-inference_INCLUDE_DIRS}
    ${jetson-utils_INCLUDE_DIRS}
    ${GSTREAMER_INCLUDE_DIRS}
    ${JSONCPP_INCLUDE_DIRS}
)

cuda_add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME}
    jetson-inference
    jetson-utils
    ${GSTREAMER_LIBRARIES}
    ${JSONCPP_LIBRARIES}
)