Cross compilation to XAVIER NX from Ubuntu 18.04

Hi Guys,

I’m developing on Qt on Ubuntu 18.04, and want the execute file will be used on Xeviar NX.
so I need to do some cross-compilation.

I read this one:
https://catalog.ngc.nvidia.com/orgs/nvidia/containers/jetpack-linux-aarch64-crosscompile-x86

but i didn’t really understand how it works. on that article there is no explanation how to use the cross compilation with LT4, how and where to choose the specific file(s) I need to compile.

can you explain me more about this?

Thanks!
Lior

I have not used docker for this, so I can’t fully answer. Someone else will end up with the end answer, but here are some details you’ll probably need to know first…

Some environments will emulate others, in which case you might end up using “native” tools. If you are running on a PC environment, but producing output to run on arm64, then you are cross compiling, and this is what my statements below assume you are doing (docker might be doing something different).

When you compile for a kernel there is no need to link to a library, and no need for libraries. Also known as kernel space. The only tool this needs is a cross compiler.

You’re compiling for an end user program, which is user space, and not kernel space. When this happens you need a cross compiler plus a linker and plus the libraries to link against. The libraries and linker are the user space requirements and it is no longer “bare metal” (it expects a user space environment). If this is a cross compile environment, then your linker must be a cross linker which runs in the PC environment, but links arm64 libraries. The libraries themselves must be arm64, and nothing on the PC can be used for that.

Beware that some libraries will link with yet other libraries. If a program links to some library “libexample.so”, it is quite possible that “libexample.so” itself links to something like “libc.so”. Whatever your program links against, either directly or indirectly, must be copied from the Jetson to your cross compile environment. A typical cross tool environment would include only the most basic of libraries, and anything else would have to be provided by you.

If your Jetson is capable of running this program (meaning the linked libraries are present already), then you can see a list of every library the linker sees:
ldconfig -p

Your program won’t necessarily use anything except a few of those. If you happen to know what your program build links against, then you can see if the requirement exists on the Jetson via “ldconfig -p”. If your cross compile environment has a cross linker already, then you could copy the libraries you need from the Jetson to the cross link path on the PC.

On the Jetson itself, if you know the name of a library you must use, then you could run the ldd command against that library to see what it is itself linked against. Example:
ldd /usr/lib/libexample.so

You can end up spending a lot of time tracing those manually. However, if you have an eMMC model, then you can clone and use the loopback mounted raw clone on the host PC and point your cross linker at this and everything you have on the Jetson will become available as a library on the PC (you’d still need the cross linker and cross compiler). If it is an SD card Jetson, then you can mount the SD card partition directly (or copy it to the PC via dd and keep the SD card on the Jetson…a good idea since this is a backup too).

The libraries on the Jetson itself might be insufficient if you have not previously set up for running your software, e.g., since you are building QT applications, perhaps you’ve never run a QT program on the Jetson itself and perhaps the needed libraries were never installed. If you can run some basic QT program on the Jetson, then either the clone of eMMC or the dd of the SD card would get all of the libraries you need.

The above assumes you are running arm64 tools and libraries on a PC, thus the “cross” name in everything. Docker could function as an “adapter” end perhaps you can use arm64 tools directly without using “cross” tools. Someone else will have to answer setup, but even if you do use an environment which can adapt to run arm64 directly on the PC, then you’d still need the libraries I mentioned above. You would still likely find that if your Jetson is set up to run your QT programs, then a clone or dd of the rootfs partition would be the simplest place to point your linker and simply have all libraries available without digging them out one at a time.

@linuxdev Thank you very much for the enlightening !

as you suggested, i was able to create a clone of my Jetson to my PC.
So, missing now the cross compilation tool.
can you recommend on any tool that can do the job?

Thanks again!

The official downloads and docs for your specific L4T/JetPack release either has the tools directly for download and install, or else provides “apt-get” commands to install. FYI, you can find your L4T release version with “head -n 1 /etc/nv_tegra_release”. Then the listing of L4T releases here will lead to tools and docs:
https://developer.nvidia.com/linux-tegra

Quite often the cross tools are not directly in the shell search path, and so even if installed, unless you know they are there, you might need to search. See if the docs to your particular release shows cross tool install (the kernel cross compile tools would work for user space, and the kernel requirements are a subset of the user space requirements…the clone won’t provide the cross linker, but it will provide the libraries once loopback mounted and the build is told of the environment…the kernel does not use cross linkers, but that’s probably included in the cross compiler tools even if the kernel never uses it).

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