Hello! I’ve been developing TX2 apps via chroot emulation for some time now but I wanted to try cross-compilation. My main thing is that I want to cross-compile user-space applications (with Argus, Qt, etc) and I am using C++20 standard.
Currently I’m compiling with GCC-11 & G+±11 on Jetson itself, so as there’s no official toolchain of GCC-11, G+±11 from Nvidia, I decided to try just installing on Ubuntu 22.04: sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
which both contain 11.4 versions (g++-aarch64-linux-gnu --version
).
Then I created a minimal .cpp project with CMake, which uses Argus. I do have entire Jetson sysroot (which I’m using to compile natively and via chroot, so all libraries are there).
I also created a toolchain.cmake
file:
# Set the system name
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
# Specify the cross compiler
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_LINKER aarch64-linux-gnu-ld)
# Specify the sysroot (change the path if necessary)
set(CMAKE_SYSROOT /home/user/rootfs)
# Ensure that the cross-compiler can find the correct headers and libraries
set(CMAKE_FIND_ROOT_PATH /home/user/rootfs)
# Search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# For libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
After that I ran Cmake like this and it was successful! It found Argus, correct aarch64 compilers and everything.
cmake -DCMAKE_TOOLCHAIN_FILE=../aarch64-toolchain.cmake ..
When I run make
, it builds fine but it fails on linking. I noticed that the ldd --version
is different between Ubuntu 22.04 and Jetson rootfs but I’m kinda stuck on this issue. It looks like a problem with glibc
. Could anyone help me or just tell me if it’s not worth it to do this?
This is the make output:
[ 33%] Building CXX object CMakeFiles/argus_oneshot.dir/ArgusHelpers.cpp.o
[ 66%] Building CXX object CMakeFiles/argus_oneshot.dir/main.cpp.o
[100%] Linking CXX executable argus_oneshot
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: /home/user/rootfs/lib/aarch64-linux-gnu/libdl.so.2: undefined reference to `_dl_vsym@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: /home/user/rootfs/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_dlclose@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: /home/user/rootfs/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_current_sigrtmax_private@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: /home/user/rootfs/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `_dl_make_stack_executable@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: /home/user/rootfs/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_vfork@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: /home/user/rootfs/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_thread_freeres@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: /home/user/rootfs/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_pthread_init@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: /home/user/rootfs/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_allocate_rtsig_private@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: /home/user/rootfs/lib/aarch64-linux-gnu/libdl.so.2: undefined reference to `_dl_addr@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: /home/user/rootfs/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_dlopen_mode@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/bin/ld: /home/user/rootfs/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_dlsym@GLIBC_PRIVATE'
Any help appreciated!