Programing Jetson Nano with C++

Hello,

i am totally newbie with Jetson Nano and i have some questions about Nano and C++ (in fact, i am a newbie for many things concerning Jetson Nano) :

Does Nano Developer Kit provides the tools to be able to create C++ programs ?

My purpose is to create C++ programs using Opencv and Cuda.

I suppose a C++ compiler is provided. If the answer is yes, which compiler is it ?

Is there an IDE for C++ provided with the developer kit ? If yes, which one, if no, which IDE pour C++ would you recommend to me ?

Is GTK+ provided with the developer kit ? It seems Qt is not provided with the Nano dev kit (we have to compile Qt if we want to use it. Am i correct ?

Would i prefer Qt rather than GTK+ ? If yes, why ?

To get opencv with Cuda, i suppose i must compile opencv 4.1.0 ?

I think i can manage opencv but concerning Cuda, do you have a pdf document which explains Cuda, step by step ?

I will make image treatment, using routines like blur, gaussain blur, denoise, sharpen, unsharp mask, histogram stretch, Clahe filter, etc. If i have to write those filters using Cuda, do you have some documentation about how to use Cuda to make such filters ?

In fact, i would like first to setup Jetson Nano to get working environment to create C++ software using opencv, Cuda, GTK+ (or Qt) quite quickly because i don’t want to spend too much time getting a working environment. I would prefer to spend my time learning C++, Cuda and GTK+ (or Qt) to develop my software.

Many thanks for your highlights !

Alain

1 Like

Yes, it provides GCC version 7.4. Because it’s Ubuntu, it could also use CLang, but you may run into compatibility problems with some C++ shared libraries if you use that.

Ubuntu comes with any number of IDEs you can install, although I’d recommend starting with something Terminal-based (vim or emacs) or the simple gedit editor to start with.
If you want VSCode, there’s for example GitHub - SteveDesmond-ca/vscode-arm: Automated builds of Visual Studio Code for Debian/Ubuntu on ARM
(Another way to install vscode: http://code.headmelted.com./#linux-install-scripts )
If you want something different, there’s Code::Blocks (sudo apt install codeblocks)
And there’s all the rest that you’d get on Ubuntu – google around for various opinions.

GTK+ is part of Ubuntu. I don’t know if it’s installed by default, or whether you need to “sudo apt install” it.
Personally, I’d prefer GTK over QT.

NVIDIA ships a specific version of OpenCV that’s built to interface with the CUDA on the system – you should use the version that’s included, rather than building your own, if you want the smoothest experience. The draw-back is that this version is 3.2, not the latest-and-greatest, but that should be OK to get you going for a long time.

Regarding using CUDA, there are a number of tutorials on the web where the CUDA-code side should work fine; the API is no different on the Tegra than on other Linux systems (although if you want to re-install it, the process is different. There’s no need to reinstall normally.) However, how to implement “unsharp mask” is in itself a question that’s not “on rails” – you’ll have to research what the filter really does, then you have to figure out how to express that in a CUDA-friendly algorithm, and then you have to implement it on top of CUDA using the existing tools – that’s not a function that someone else has “solved” for you, and there’s no “copy and paste” solution to that.

Good luck!

1 Like

Many thanks snarky for all those informations.

I will have to learn a lot of things.

I will probably come back soon with more questions !

Alain

Actually, the installation script has a problem (I just tried it on my Nano.)
You will need to run these commands to install code-oss: (Visual Studio Code for ARM64)

wget https://packagecloud.io/headmelted/codebuilds/gpgkey -O headmelted_key.gpg
sudo apt-key add ./headmelted_key.gpg 
sudo . <( wget -O - https://code.headmelted.com/installers/apt.sh )

The first two steps are not in the instructions for APT on that page, and the third step will fail without them.

Many thanks snarky.

Those IDE seem really interesting. I will take a look closely at :

  • Code::Blocks
  • Dev-C++
  • Visual Studio Code

A question to Nvidia : which IDE would you recommand to me for Python and C++ programming ?

Alain

NVIDIA offers an eclipse plugin with Jetson Jetpack called Nsight Eclipse Edition to enable a CUDA remote visual debugging experience and cross compiling from a PC to Jetson.

Simultaneously NVIDIA offer flexibility via CLI tools like cuda-gdb and compilers. These allow developers to work in whichever IDE or document editor they desire in the end regardless of if the want to do their Jetson development from a remote Linux PC or on the Jetson device.

Many thanks for your reply kayccc.

Alain

$ cd ~/Downloads/
suryadi@nona:~/Downloads$ wget https://packagecloud.io/headmelted/codebuilds/gpgkey -O headmelted_key.gpg
--2019-08-21 13:46:01--  https://packagecloud.io/headmelted/codebuilds/gpgkey
Resolving packagecloud.io (packagecloud.io)... 52.8.147.134, 54.183.241.58, 2600:1f1c:2e5:6900:5174:4b7e:e606:ac27, ...
Connecting to packagecloud.io (packagecloud.io)|52.8.147.134|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://d28dx6y1hfq314.cloudfront.net/3487/3704/gpg/headmelted-code-oss-0CC3FD642696BFC8.pub.gpg?t=1566370262_5ed53aa442361ee179c4943dadd1c39ca61b2e93 [following]
--2019-08-21 13:46:02--  https://d28dx6y1hfq314.cloudfront.net/3487/3704/gpg/headmelted-code-oss-0CC3FD642696BFC8.pub.gpg?t=1566370262_5ed53aa442361ee179c4943dadd1c39ca61b2e93
Resolving d28dx6y1hfq314.cloudfront.net (d28dx6y1hfq314.cloudfront.net)... 13.35.20.78, 13.35.20.171, 13.35.20.166, ...
Connecting to d28dx6y1hfq314.cloudfront.net (d28dx6y1hfq314.cloudfront.net)|13.35.20.78|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3949 (3,9K) [text/plain]
Saving to: ‘headmelted_key.gpg’

headmelted_key.gpg                      100%[==============================================================================>]   3,86K  --.-KB/s    in 0s      

2019-08-21 13:46:02 (234 MB/s) - ‘headmelted_key.gpg’ saved [3949/3949]

suryadi@nona:~/Downloads$ sudo apt-key add ./headmelted_key.gpg
Ok.
  
$ sudo . <( wget -O - https://code.headmelted.com/installers/apt.sh )

Redirecting output to ‘wget-log.1’.
sudo: .: command not found
suryadi@nona:~/Downloads$ --2019-08-21 13:48:30--  https://code.headmelted.com/installers/apt.sh
Resolving code.headmelted.com (code.headmelted.com)... 104.27.187.80, 104.27.186.80, 2606:4700:30::681b:ba50, ...
Connecting to code.headmelted.com (code.headmelted.com)|104.27.187.80|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-sh]
Saving to: ‘STDOUT’

-                                           [ <=>                                                                           ]       0  --.-KB/s    in 0s      

Cannot write to ‘-’ (Success).

Sudo: .: command not found.

OK, the default shell doesn’t want to read the script as input then?

Instead of that one line, do these three lines:

wget -O code-apt.sh https://code.headmelted.com/installers/apt.sh
chmod a+x code-apt.sh
sudo ./code-apt.sh

Fwiw I like CLion. It’s not free, but I think there is a trial period you can use to see if you like it. Sometimes JetBrains also has special offers, and if you’re lucky you can get a full product pack for not much more than a single product. Respond to this post if you’d like instructions setting up remote development using CLion.

Hello mdegans,

many thanks for those informations. I will take a look at CLion.

Have a nice day.

Alain

Have fun. Setting it up with the nano is a fairly simple two step process. You must have ssh set up on the nano (sudo apt install openssh-server) and cmake installed already (sudo apt install cmake), but that’s all.

Then you go to the “Build, Execution, Deployment” > “Toolchains” in CLion’s settings and add a “remote host” toolchain for nano using the credentials for your user. Both password and key authentication are supported. When you’re set up it should look like this:

CLion will automatically determine the CMake version, compiler, etc. I believe only CMake remote debug is supported so far but Gnu make might work also (i have never tested it). The above only has to be done once per installation. Once you’ve configured the toolchain, you can set it to be used on a per-project basis below:

You can tell if something is a per project setting or not by looking at the top of the window. If it says “for current project” you know you’ll have to set it each time you create a new one.

Once it’s all set up, you can develop as you would locally and files will automatically be copied to and from the nano, including headers, when they’re needed.

If you get stuck or run into problems (file sync sometimes), more verbose instructions are here.

You also may have to change the generation path if you reboot your nano since /tmp is cleared out and CLion isn’t smart enough to create it again if it goes missing. I usually just add and remove an underscore to the “generation path” and it’ll force it to regenerate the path in the nano’s /tmp

Hi,
I am trying to setup remote development using CLion for jetson-inference repo (GitHub - dusty-nv/jetson-inference: Hello AI World guide to deploying deep-learning inference networks and deep vision primitives with TensorRT and NVIDIA Jetson.)
Can’t figure out, if it even possible, taking in account, that last step uses Makefile.
Any ideas?

Hi k29jnzk, I’m not familiar with CLion, but on this page it states that “the current setup assumes the source code is located on a local machine, which CLion synchronizes to the remote machine.” I am not sure if that would prevent it from working with jetson-inference repo or not, jetson-inference also runs local scripts during the initial config/build process that download DNN models to the Jetson, create symbolic links, ect.

It works. I use it with my Nano. I will provide my configuration in a bit. I can also confirm it does build jetson-inference, specifically.

Oh wait. (Scrolled up). Does this not work?

If you are using GNU make or something else you make need a plug-in, but I haven’t checked remote development and debug works. With Cmake it works out of the box.

Hi @mdegans. Thanks for the info on CLion. I’ve just downloaded it for the 30-day trial to check it out. I’ve setup my remote as per your screen shots and the documentation but I don’t really get the overall development workflow.

It seems that if you want to create a new project -it creates it on your local machine and then syncs it across to the nano. So as you make your changes it syncs them to the nano and builds them on the nano - all in a /tmp directory.
I assume that when you do a make install it installs it on the nano and not the local machine but I haven’t tested yet


What I don’t get is how you open a project that may already exists on the nano? There seems to be no way to do this in CLion.

Also - how would you work on a deepstream app for example
 Would you would have to install deepstream and all dependencies on the host as well, right? Then CLion would copy ALL of that to the nano to build?

It does copy it to /tmp to build on the remote. It uses rsync internally to copy stuff. You may have to manually change the temp path in the settings, forcing it to resync, if the dir already exists when you re-open a project and clion complains. This seems like an unforgivable lack of testing. The sync has more than a few issues.

Re: make install I think you can do that from a terminal (lanuched either manually or via the built in) but it can launch a build target for you directly on the nano and pipe the output to your screen. You can pretend it’s local for the most part.

Re: opening an existing project on the nano, I don’t think you can. You’ll have to copy the files over to your desktop. With VScode you can’t do that but it has no c/cpp code completion at the moment on aarch64. It does with python. It does with Vala if you build it’s language server.

Re installing DeepStream on the host. Nope. The sync is two way so it copies the development headers in the paths you specify (eg. In CMakeLists), back to your machine so you can have all the (not technically) intellisense goodness. It works as it does locally.

I know this thread is a year old but I wanted to say I have been using Qtcreator natively on my Jetson Nano.
Is it possible for the other IDEs above to do that? I will admit it is a little quirky at the compile time but I have
learned to cope so far.

I am using open source licensing version of Qt. I want to be able to share my code but don’t know which license
to use. LGPL, GPLv2 or GPLv3. My apps have guis and I can ssh -X into them headless.

If I was to use Nsight Eclipse would I have to cross compile on my Desktop and then port to the Nano? Also what
license would I use?

Andy in Yakima