Cross compile Opengl apllication for tx1

How can I cross-compile my application for tx1?

For now, we can only use Nsight connecting to a tx1 board to build openGL applications. I hope to build the application on a x86_64 server. Is there any ways to do so?

I can’t answer your specific question, but you can think of two types of cross-compile: Those which only need the tool chain with no outside dependencies on an operating system (includes U-Boot and the kernel), and everything else which runs within the operating system (user space).

Kernel space is simple as you just need the tools. User space adds to those requirements because you must also present a cross-system set of files for linking against and support within the operating system. Cross compile tools would generally classify this as the sysroot. Minimal sysroot is linking and the minimal libc support. In your case you would also require everything related to OpenGL. Those OpenGL and other linker type files would be for the arm64 environment.

The complexity of that can be somewhat daunting. I’d advise first learning to cross compile a simple hello world type application on command line. See the Linaro tools and documentation for more information on this:
https://releases.linaro.org/components/toolchain/binaries/
…files named after aarch64/arm64/armv8l are what you are interested in. If it has “linux-gnu” in the name (think aarch64-linux-gnu), then you’re talking user space support. Ignore armhf, eabi, or gnueabi, these are 32-bit. If your host is Ubuntu, then many of those packages will be available directly for apt-get install.

You’ll find a division of three package types: The tools themselves (gcc-linaro), the linking environment support (runtime), and the packages which are the minimum system library support (sysroot). It is this latter you will have the most difficulty with as you will eventually need to customize it with all of the OpenGL goodies and everything else your application links with which is not present in the minimal sysroot. I tend to clone my Jetson and loopback mount it for my sysroot (editing required, e.g., I use symbolic links in places). It won’t be fast or easy…if eclipse works to take care of any of that you should probably do it that way. Native builds directly on the TX1 would avoid all of this.

Incidentally, if you have an OpenGL application running on the Jetson, and you want to see what has to be available to build that package, run “ldd” on the executable to see a list of library dependencies you’ll have to provide in your sysroot.

Thanks. I will give it a try.

By the way, I understand we could cross-compile C/OpenCL using aarch64-g++, can cuda codes also be cross-compiled?

Someone who knows nvcc would have to answer that…the question would be whether the correct cross-environment nvcc exists (it’s only a question of whether there is a cross tool).

in ubuntu16.04lte, we try to cross-compile the app, at linking stage, faced with the following error:

Invoking: NVCC Linker
/usr/local/cuda-8.0/bin/nvcc --cudart static -L/usr/local/lib -L/usr/lib/aarch64-linux-gnu/tegra -L/usr/lib/aarch64-linux-gnu --relocatable-device-code=false -gencode arch=compute_50,code=compute_50 -gencode arch=compute_50,code=sm_50 -m64 -ccbin aarch64-linux-gnu-g++ -link -o “OmniViewer_d”
… xxx.o
-lGL -lGLEW -lopencv_videoio -lopencv_core -lglut -lGLU -lopencv_imgcodecs -lzbar -lopencv_imgproc -lopencv_calib3d -lopencv_highgui
/usr/lib/gcc-cross/aarch64-linux-gnu/5/…/…/…/…/aarch64-linux-gnu/bin/ld: warning: libnvidia-tls.so.24.2.1, needed by /usr/lib/aarch64-linux-gnu/tegra/libGL.so, not found (try using -rpath or -rpath-link)
/usr/lib/gcc-cross/aarch64-linux-gnu/5/…/…/…/…/aarch64-linux-gnu/bin/ld: warning: libnvidia-glcore.so.24.2.1, needed by /usr/lib/aarch64-linux-gnu/tegra/libGL.so, not found (try using -rpath or -rpath-link)
/usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv017glcore' /usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv016glcore’
/usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv000glcore' /usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv017tls’
/usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv013tls' /usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv007tls’
/usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv009tls' /usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv014glcore’
/usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv015glcore' /usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv001glcore’
/usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv024glcore' /usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv008tls’
/usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv006tls' /usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv021tls’
/usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv023glcore' /usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv011tls’
/usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv020glcore' /usr/lib/aarch64-linux-gnu/tegra/libGL.so: undefined reference to _nv027glcore’
collect2: error: ld returned 1 exit status
makefile:60: recipe for target ‘OmniViewer_d’ failed
make: *** [OmniViewer_d] Error 1

update:
this is solved by referring to the following link.
https://devtalk.nvidia.com/default/topic/853316/nsight-example-build-not-finding-x11-libraries/

a bit more info:
since out opencv3.0 was build on board(unbuntu16.04), the 14.04 cross-compiler cannot link it due to the g++4.8’s failure to support cxx11 standard. we had to upgrade to 16.06 and use g++5 to do cross-compile.