Jetson Nano CPP Support

Hello again,

I am trying to find support and resources that would help me build a motion tracking system using Jetson Utils and my Jetson Nano in C++.

Any suggestions on where to get started? thanks

Suggest to check those projects sharing at Latest Jetson & Embedded Systems/Jetson Projects topics - NVIDIA Developer Forums see if can gain some ideas.

Sorry long night, I will give more detail.

I have some code that I’d like to compile and run but my header files are not being recognized. I have the Jetson Inference downloaded, though I am not super familiar with C++ yet so I cant figure out why they aren’t seeing them.

#include <jetson-utils/cudaMappedMemory.h>
#include <jetson-utils/cudaNormalize.h>
#include <jetson-utils/cudaFont.h>
#include <jetson-inference/loadImage.h>
#include <jetson-inference/saveImage.h>
#include <jetson-inference/cudaUtility.h>
#include <jetson-utils/gstCamera.h>



Jetson utils is a submodule.
Have you initiated it with the following command?

$ git submodule update --init


Hi @jpbaehr13, see this example CMakeLists for setting your C++ project up to include/link to jetson-inference:

1 Like

Incidentally, when you see a statement of this format:

#include <some/thing.h>

It means to look for subdirectory “some/” of a “standard” search location, and look for file “thing.h”. The normal “standard” location is “/usr/include”. Your CMake or Makefile (depends on which you are using…you might not use either) can list options to add other “standard” locations in addition to the one the operating system as a whole uses. Normally, if you see this:

#include <jetson_utils/cudaMapperMemory.h>

…then it is looking for “cudaMapperMemory.h” at “/usr/include/jetson-utils”.

The “#include <iostream>” is somewhat different. The regular “.h” files are C syntax, and C++ uses them more or less the same. The ones without the suffix tend to go to a C++ subdirectory of the standard directory (and often named after a specific C++ release). So that is an extension of the C theme. As an example, on a TX2 I have program g++ (the C++ compiler which is free on Linux) version 7.5.0. Because this has:

It is in that directory where “iostream” lives.

If your build system adds the right argument, then it might also look at “/usr/local/include”. Or any other variant. Jetson projects will tend to name a location for their header files. What other people have mentioned to add libraries just adds the libraries to where those search locations are looking.

Okay, I think I am starting to understand a little bit more on how these file types work with each other.

Currently I decided to start simple, here is some code I wrote. I wrote this and made it a goal to #include the libraries I am having trouble with. I have a project folder located outside of Jetson-Inference, which has a main.cpp, a CMakeLists.txt, and a quick setup build folder. I built the project to test it before adding the following library.
#include <iostream.>
#include <jetson-utils/cudaMappedMemory.h>
using namespace std;

int main()
cout << “Hello”;
return 0;

AND my CMakeLists.txt

cmake_minimum_required(VERSION 3.0.0)

project(main VERSION 0.1.0)





cuda_add_executable(main main.cpp)

target_link_libraries(main jetson-inference)





So now, I am getting that same error as before with the #include <jetson-utils/cudaMappedMemory.h>. Should I be including the entire path to that header file?

On top of that my CMakeLists.txt is yelling at me that I need to include jetson-utilsConfig.Cmake.


This file should automatically get installed under /usr/local/share/jetson-utils/cmake when you ran sudo make install after building jetson-inference. If you didn’t run sudo make install from your jetson-inference/build directory, please do so now.

Can you confirm that the headers are installed under /usr/local/include/jetson-inference and /usr/local/include/jetson-utils ?

1 Like

Thanks for getting back to me

I have rebuilt the jetson-inference and followed proper guides. I currently only see the cmake folder for both the jetson-inference and jetson-utils, under /usr/local/include

In those folders I do in fact see the headers now. Originally I made this reply saying i didn’t see them but realized I went into the wrong folder.

So now I have the headers, using them shouldn’t be an issue now? I will try now

Okay, everything seems to pulling from correct locations now.

What is the best way to compile this, that uses CUDA headers? Should I be using nvcc or g++?

Update Code:

#include <jetson-utils/cudaMappedMemory.h>

#include <jetson-utils/cudaNormalize.h>

#include <jetson-utils/cudaFont.h>

#include <jetson-utils/loadImage.h>

#include <jetson-utils/imageWriter.h>

#include <jetson-utils/cudaUtility.h>

#include <jetson-utils/videoSource.h>

using namespace std;

int main()


cout << “Hello”;

return 0;


When I try to build with g++, in Visual Studio, I get this error:
Starting build…
/usr/bin/aarch64-linux-gnu-g+±7 -fdiagnostics-color=always -g /home/sam/projects/main.cpp -o /home/sam/projects/main
In file included from /usr/local/include/jetson-utils/cudaMappedMemory.h:27:0,
from /home/sam/projects/main.cpp:2:
/usr/local/include/jetson-utils/cudaUtility.h:27:10: fatal error: cuda_runtime.h: No such file or directory
#include <cuda_runtime.h>
compilation terminated.

Build finished with error(s).

Thanks and have a great weekend!

To fix this issue, I added

export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64{LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

in my /.bashrc by doing

nano /home/USER_HERE/.bashrc

Now when I do
nvcc main

It successfully compiles the code and outputs when the main file is ran

This can be closed, as I will open another topic for some more in depth discussion on now using this to right scripts for my camera! Thanks

1 Like

OK thanks @jpbaehr13, glad that you were able to get it working! Typically I use CMake which imports NVCC and the CUDA libraries, but if you are calling it directly then setting those environment variables seems to be a good solution 👍

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.