Tutorial on compiling x86_64 packages from main repo for aarch64

There are some ROS packages from the main Ubuntu repo that services x86_64 that are not available for the aarch64 version of the repo.

I was pointed in the direction of compiling my own packages with the help of the GCCToolChain. Is there a tutorial I could follow to learn how I could compile on my own?

Keep in mind that your Jetson is likely good at building the software directly on it. You might want to mount a hard drive or SD card in the build area for space, but this would give you a much easier method of doing this (assuming it is straight forward even in the native PC build).

If you choose to cross compile and use an Ubuntu 14.04 or 16.04 host PC, then JetPack has the tools with it (or will download the tools through apt).

The documentation download with L4T shows information on kernel cross compile. This is the initial component of any other cross build environment. A kernel does not rely on external libraries or an operating system to provide services…it is the kernel itself doing this. This is “bare metal” and is the simplest of all.

As soon as you add user space components (not kernels, not drivers…things which run as an ordinary program) you need tools to link to the aarch64 libraries. Plus you need the libraries themselves…you can’t link against the PC’s libraries, nor can you use the utilities of the PC which do the linking. On the PC the tools which do this for the PC itself are the native tools, and the architecture for cross linking or cross compiling are known as the foreign architecture. Basically the files linked against are known as the sysroot. So you need the cross compiler, the binary manipulation tools, and the sysroot if you go outside of kernels or drivers within the kernel (or perhaps the boot loader…this too is bare metal).

Thus I suggest follow the documentation download to learn about kernel cross compile…this is fairly complete. Then try simple user space cross compiles…this will require adding the correct cross binutils to do the work. You might clone your Jetson’s rootfs and loopback mount it as a source of a sysroot exactly matching your Jetson…or you might get the Linaro sysroot (Linaro won’t be as complete). See:
https://releases.linaro.org/components/toolchain/binaries/

Note: Much of what is built on a Jetson uses the 4.8.5 compiler. Recently a version 5.x compiler was used. For user space you might be interested in using the newest 7.x series…but don’t do this until you know you can work with the 4.x or 5.x series first since there may be changes in the compilers over time which will require an adjustment. If you get the original 4.x tools working with the build environment, and only then transition to a newer 7.x version you will probably save yourself some confusion. Some software will demand a certain version, so this is just a rule of thumb.

Perhaps someone knows of a good tutorial. eLinux.org and jetsonhacks.com are probably a good place to look around, especially for ROS (which I have not personally used…jetsonhacks.com in particular has much related to drones and ROS type development).