Using Nsight Eclipse Edition with OpenCV for Cross Compilation?

Has anyone managed to successfully run opencv in cross-compilation mode with the tegra devices? I can run the basic CUDA example mentioned in this blogpost -

But when I try to add OpenCV into the mix it seems to fail.

What I’m currently doing is:

Step 1: Do everything mentioned in blogpost above
Step 2: Go to Project > Properties > Build > Settings > NVCC Compiler > Includes
Then I add “/usr/include/opencv" to the <b>Include paths (-l)</b> Step 3: Go to Project > Properties > Build > Settings > NVCC Linker > Libraries Then I add "/usr/lib” to the Library search path (-L)
Step 4: Then I add opencv_imgproc , opencv_core , opencv_highgui to the Libraries (-l)

Step 5: I then copy over the library files from the TX2 as follows
sudo scp nvidia@IP_ADDRESS:/usr/lib/<b></b> /usr/aarch64-linux-gnu/lib sudo scp nvidia@IP_ADDRESS:/usr/lib/ /usr/aarch64-linux-gnu/lib
$ sudo scp nvidia@IP_ADDRESS:/usr/lib/ /usr/aarch64-linux-gnu/lib

To test that it’s working in the boxFilter.cpp code mentioned in the example

I include the following headers
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

and try to create a Matrix variable in the main function
cv::Mat img;

This is the error that I get, I can’t seem to figure out what I’m doing wrong. Has anyone tried this before?

16:14:00 **** Incremental Build of configuration Debug for project test-tx2 ****
make all 
Building target: test-tx2
Invoking: NVCC Linker
/usr/local/cuda-8.0/bin/nvcc --cudart static -L"/usr/local/cuda-8.0/samples/common/lib/linux/aarch64" -L"usr/lib" -lGL -lGLU -lglut  -Xlinker --unresolved-symbols=ignore-in-shared-libs --relocatable-device-code=false -gencode arch=compute_60,code=compute_60 -gencode arch=compute_60,code=sm_60 -m64 -ccbin aarch64-linux-gnu-g++ -link -o  "test-tx2"  ./src/boxFilter.o ./src/boxFilter_cpu.o ./src/boxFilter_kernel.o  /usr/local/cuda-8.0/samples/common/lib/linux/x86_64/libGLEW.a -lopencv_imgproc -lopencv_core -lopencv_highgui
/usr/lib/gcc-cross/aarch64-linux-gnu/4.8/../../../../aarch64-linux-gnu/bin/ld: test-tx2: hidden symbol `cudaGetDeviceCount' in /usr/local/cuda-8.0/bin/../targets/aarch64-linux/lib/libcudart_static.a(libcudart_static.a.o) is referenced by DSO
/usr/lib/gcc-cross/aarch64-linux-gnu/4.8/../../../../aarch64-linux-gnu/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make: *** [test-tx2] Error 1

Any leads are appreciated,


May I know which opencv version do you use?
For opencv4tegra, please refer to this topic first:


This is probably not the cause of your build error, but you are building for a CUDA 6.0 architecture.
Unless you deliberately want this, for TX2 you should use 6.2 (compute_62 and sm_62).

I’m using the latest JetPack 3.0 with opencv4tegra.

I followed the thread mentioned above and I still get an error while trying to use cv::imread, cv::imwrite, cv::putText etc…

I installed gcc version 5.4.1 using sudo apt-get install on my host machine and moved all the libopencv_*.so files to the host machine as instructed, but still no luck.

The way my nsight is setup, the maximum ptx_code and gpu_code architecture versions are 6.0. Should I be manually switching it to 6.2 somewhere else?


Please upgrade cross-compiler to g++5.4.

You can check by this:

/user/bin/aarch64-linux-gnu-g++ --version

Sorry for the novice question, but could you point me in the direction of a tutorial on upgrading the cross compiler from the source binaries?


  1. Please download the cross-compiler mentioned above.
  2. Unzip the file
  3. Copy the file to /usr/*


Hi AastaLLL,

So I still can’t figure out how to get it to work. Please excuse the silly questions.

This is what I’ve done so far.

Remove the older version (4.8)

  1. $ sudo apt-get remove g+±4.8-aarch64-linux-gnu
  2. $ sudo apt-get autoremove

Download and configure new cross-compiler

  1. Download gcc-linaro-5.4.1-2017.01-x86_64_aarch64-linux-gnu.tar.xz
  2. $ tar xf gcc-linaro-5.4.1-2017.01-x86_64_aarch64-linux-gnu.tar.xz
  3. Move this folder to /usr/ such that it is at /usr/gcc-linaro-5.4.1-2017.01-x86_64_aarch64-linux-gnu
  4. Add the binary file to the $PATH variable in ~/.bashrc
    export PATH=/usr/gcc-linaro-5.4.1-2017.01-x86_64_aarch64-linux-gnu/bin:$PATH

I verified that it is the correct compiler by the following
$ aarch64-linux-gnu-g++ --version

aarch64-linux-gnu-g++ (Linaro GCC 5.4-2017.01) 5.4.1 20161213
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

Launch nsight, create new CUDA/C++ Project from boxfilter-arm etc. etc.
Add the “Library search path(-L)” to point to linux/aarch64
Add a new -Xlinker option --unresolved-symbols=ignore-in-shared-libs

Copy over files from device to host
sudo scp ubuntu@your.ip.address:/usr/lib/aarch64-linux-gnu/ /usr/aarch64-linux-gnu/lib sudo scp ubuntu@your.ip.address:/usr/lib/aarch64-linux-gnu/tegra/ /usr/aarch64-linux-gnu/lib
sudo scp ubuntu@your.ip.address:/usr/lib/aarch64-linux-gnu/ /usr/aarch64-linux-gnu/lib sudo scp ubuntu@your.ip.address:/usr/lib/aarch64-linux-gnu/ /usr/aarch64-linux-gnu/lib
sudo ln -s /usr/aarch64-linux-gnu/lib/ /usr/aarch64-linux-gnu/lib/ sudo ln -s /usr/aarch64-linux-gnu/lib/ /usr/aarch64-linux-gnu/lib/
sudo ln -s /usr/aarch64-linux-gnu/lib/ /usr/aarch64-linux-gnu/lib/ sudo ln -s /usr/aarch64-linux-gnu/lib/ /usr/aarch64-linux-gnu/lib/

When I try to build this example with the new cross compiler, I get the following error

09:07:33 **** Build of configuration Debug for project boxfilter-arm ****
make all 
Building file: ../src/boxFilter.cpp
Invoking: NVCC Compiler
/usr/local/cuda-8.0/bin/nvcc -I"/usr/local/cuda-8.0/samples/3_Imaging" -I"/usr/local/cuda-8.0/samples/common/inc" -I"/home/shreyasskandan/cuda-workspace/boxfilter-arm" -G -g -O0 -ccbin aarch64-linux-gnu-g++ -gencode arch=compute_60,code=sm_60 -m64 -odir "src" -M -o "src/boxFilter.d" "../src/boxFilter.cpp"
In file included from ../src/boxFilter.cpp:29:0:
/usr/local/cuda-8.0/samples/common/inc/helper_gl.h:23:23: fatal error: GL/gl.h: No such file or directory
compilation terminated.
make: *** [src/boxFilter.o] Error 1

09:07:33 Build Finished (took 55ms)

You may try this :

Thanks for the link but that still doesn’t seem to fix the problem sadly.


Sorry for the late update.

Please try to add some configuration into Nsight:
Properties -> Build -> Settings -> Tool Settings -> NVCC Compiler -> Includes:


In this previous post:

it says to select 6.2 and I agree with this, but Nsight Eclipse shipped with the JetPack 3.0 does not offer 6.2, the last option I can select from the project build settings is 6.0. How can I manually select sm 6.2? Thank you.

Hi vincentroberge,

Thanks for your feedback.
We are checking this issue internally. Will update to you soon.

Hi vincentroberge,

Please use ‘Expert setting’ to add ‘-gencode arch=compute_62,code=sm_62’ option: (both NVCC compiler and linker)

1. NVCC Compiler:
Properties -> Settings -> Tool Settings -> NVCC Compiler -> Expert Setting:

${COMMAND} ${FLAGS} -gencode arch=compute_62,code=sm_62 ${OUTPUT_FLAG} ${OUTPUT_PREFIX} ${OUTPUT} ${INPUTS}

2. NVCC Linker:
Properties -> Settings -> Tool Settings -> NVCC Linker -> Expert Setting:

${COMMAND} ${FLAGS} -gencode arch=compute_62,code=sm_62 ${OUTPUT_FLAG} ${OUTPUT_PREFIX} ${OUTPUT} ${INPUTS}

Please let us know the results.

Thank you AastaLLL. YOur solution works.