Cross-Compile ROS2 C++ application that runs on Orin NX board

I have a C++ application that needs to cross-compile. Here’s the details:

  1. The target device is Jetson Orin NX board with Jetpack 6.1. The host machine is a X86-64 Linux machine that runs NVIDIA cross-compile container (nvcr.io/nvidia/jetpack-linux-aarch64-crosscompile-x86:6.1)
  2. My application has complex dependencies, includes but not limited to: ROS2, libargus, flatbuffers, opencv, SOEM, …
  3. I’m using this instruction page for how to use the container: JetPack Cross Compilation container | NVIDIA NGC

My understanding is that the container above has NVIDIA related libraries (which is libargus in my case), but it still missing some libraries (e.g. ROS2) in sysroot for building my own application, so I have to manually cross-compile these dependency libraries and put them into sysroot first. - Is this correct?

If so, this will led to a completely dependency hell. Is there a way to make this cross-compile easier? Any help would be greatly appreciated!

Hi,
The method of setting cross-compiling environment is stated in

Jetson Linux API Reference: Setting Up Cross-Platform Support | NVIDIA Docs

One is to clone the image out and mount to host. The other is to use the docker. ROS2 are not included by default so you would need to manually add required libs.

Thank you for the response.

I’d like to try “Clone the target rootfs to host system” method, since cross-compile all dependencies are too painful. My Orin NX board uses a thirdy-party carrier board, so the flashing steps and scripts are slightly different from NVIDIA official documents. The Orin NX board already installed Jetpack 6.1 + 3rd-party BSP. After flashing the board, I installed all build-time and run-time dependencies on Orin NX board, and successfully native compiled the application.

@DaneLLL I have questions about the step 1 of your shared link. In “To clone a Jetson device and flash” section, is “step 1&2” running in host machine? - If so, is it means the rootfs that I cloned won’t include libraries that installed after the flashing? - If this is the case, is there a way to clone the entire rootfs directly from Orin NX board (so all dependencies installed after flashing the board are contained in the rootfs)?

Hi,
You can clone it out once the rootfs on Orin NX is ready. For example, the sample rootfs does not include SDK components such as CUDA, TensorRT. For getting rootfs for production, it will be like:

  1. Flash system image with sample rootfs
  2. Install SDK components
  3. Clone the image out
  4. In production line, flash the cloned rootfs. So the SDK components are included

So you can construct the rootfs to include ROS2 packages and the clone it out.

@DaneLLL “3. Clone the image out” - Did you mean creating a raw disk image of my Orin NX root partition with tools like dd?

The problem is that partition size for the rootfs is around 1.9T. I think cloning the whole rootfs would be very time consuming and it’s not easy to replicate. Is it possible to clone rootfs partially as a raw image and loopback mount into the host machine?