i’m also interested in having an alternative to native compilation, although from reading various threads it seems like no single alternative (cross compilation with nvidia-provided toolchains, cross compilation with other toolchains, or native compilation) is ‘best’ or handles all use cases.
as an alternative to native compilation, i’ve been experimenting with using various methods. one method in particular seems to work in initial testing for me – i can compile a binary with dependencies on 50+ ubuntu 16.04 arm64 packages (including some ROS packages) on my host, copy it to the PX2 where i install the deps with apt, and run the binary without error (albeit with only minimal testing so far).
similar to the ‘hybrid’ method described in the PX2 docs, i created an arm64 chroot on the host (created using qemu-debootstrap via ‘mk-sbuild --arch=arm64 xenial’ ), and then install the PX2-specific debs into that chroot. see see: https://wiki.debian.org/Arm64Qemu for some background.
then, you have a couple options for compilation:
- you can use the ubuntu/debian provided cross-compiler that targets arm64, and point sysroot to the chroot (at least after making all the symlinks in the chroot relative by using (inside the chroot!) ‘symlinks -cro /lib /usr/lib /etc | tee /root/symlinks-cro-lib-usr-lib-etc.out’ or similar ). this is how i build my custom binary.
- you can compile inside the chroot (under qemu emulation), which is pretty slow, but uses host RAM/CPU, doesn’t need the actual PX2 hardware, and should allow ‘out of the box’ building of most packages (maybe? this is how i build libprotobuf3, since i had trouble building it using the cross-compiler+sysroot method). aside from having the nvidia .deb’s installed in the chroot, this is a pretty ‘vanilla’ method for ubuntu/debian cross compilation.
of course, this means that you’d be mixing the maybe-compiled-with-older-gcc nvidia libs with the ‘stock’ ubuntu ones, but that seems to be how things are on the PX2 itself?
note 1: another method i tried was to use multiarch support to install arm64 versions of development packages alongside the host cross compiler in a host-native ubuntu chroot (or not even using a chroot, for the brave). this worked in some cases, but it seems like multiarch support for devleopment is still pretty immature, and i ran into various walls i was unable to work around, in particular related to lack of python multiarch support. but, it did seem promising!
note 2: in order to speed up compilation inside the chroot, i’ve read that is should be possible to compile static native (amd64) gcc binaries that target arm64 (but named ‘gcc/g++’ as normal, not named as differently like ‘normal’ cross compilers) that can be inserted in the chroot, similar to the static qemu binary itself. if this was done, then the main disadvantage of compiling inside the chroot would be removed.
i’m just learning/experimenting with all this myself, so i welcome any comments/advice!