Specify the target rootfs path in Cross Compile on Jetson AGX Xavier

I want to build an environment for cross-compile on my host computer(ubuntu)
and I fellow this guide Jetson Linux API Reference: Setting Up Cross-Platform Support | NVIDIA Docs

I downloaded Linux_for_Tegra from SDK manager and gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu

after finishing below steps
$ cd $HOME
$ mkdir -p jetson
$ sudo mount -t ext4 clone.img.raw jetson
$ export TARGET_ROOTFS=$HOME/jetson

$ export PATH=<CROSS_COMPILER_PATH>/bin:$PATH
$ export CROSS_COMPILE=aarch64-linux-gnu-

I enter the path /jetson/usr/src/jetson_multimedia_api/samples/02_video_dec_cuda
and try to make the example

but pop the error message
…/Rules.mk:52: *** Please specify the target rootfs path if you are cross-compiling. Stop.

I can’t figure out what happen, because I already set export TARGET_ROOTFS=$HOME/jetson

thanks for sharing your solution

Hi mike.li3

  1. What’s the version of JetPack do you use?
  2. Please help to check /usr/src/jetson_multimedia_api/samples/Rules.mk if exists in your device
1 Like

JetPack_5.0.2_Linux_JETSON_AGX_XAVIER_TARGETS
I delete the clone.img.raw and want to clone another clone.img.raw
but I encounter a new error
EFI system partition image (esp.img) not found
please tell me what I can do
thanks

Could you help to use gcc-9.3 toolchain(which is compatible with JetPack_5.0.2) instead of gcc-7.3?
https://developer.nvidia.com/embedded/jetson-linux/bootlin-toolchain-gcc-93

You have tried sample 02_video_dec_cuda FAILED
How about other samples?

1 Like

I tried other example 05, 06 but still the same
…/Rules.mk:52: *** Please specify the target rootfs path if you are cross-compiling. Stop.

I download your link and change <CROSS_COMPILER_PATH> into aarch64–glibc–stable-final
and tried those examples but still got wrong rootfs path

update:
I have /usr/src/jetson_multimedia_api/samples/Rules.mk in the folder

Hi mike.li3

…/Rules.mk:52: *** Please specify the target rootfs path if you are cross-compiling. Stop.
=> This might be permission issue, it can’t get TARGET_ROOTFS when you are compiling. Please try to execute command in su mode.

Or just execute in a line:
ex. $ sudo TARGET_ROOTFS=$HOME/jetson PATH=<CROSS_COMPILER_PATH>/bin:$PATH CROSS_COMPILE=aarch64-linux-gnu- make

1 Like

previously, I always executed sudo make but it didn’t work
I execute your command it works but why I can’t use export environment variable like original steps
after execute the command, the follow error is
Linking: jpeg_decode
/usr/lib/gcc-cross/aarch64-linux-gnu/9/…/…/…/…/aarch64-linux-gnu/bin/ld: skipping incompatible /home/mikeli/jetson//usr/local/cuda/lib64/libnvjpeg.so when searching for -lnvjpeg
/usr/lib/gcc-cross/aarch64-linux-gnu/9/…/…/…/…/aarch64-linux-gnu/bin/ld: skipping incompatible /home/mikeli/jetson//usr/local/cuda/lib64/libcudart.so when searching for -lcudart
/usr/lib/gcc-cross/aarch64-linux-gnu/9/…/…/…/…/aarch64-linux-gnu/bin/ld: cannot find -lcudart
collect2: error: ld returned 1 exit status
make: *** [Makefile:53: jpeg_decode] Error 1

does it mean I lack some files in cross compiler?

This error is caused from CUDA
Please help to modify Rule.mk
CUDA_PATH := /usr/local/cuda => /usr/local/cuda-11.4

1 Like
Compiling: jpeg_decode_csvparser.cpp
Compiling: jpeg_decode_main.cpp
Linking: jpeg_decode
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /home/mikeli/jetson/usr/lib/aarch64-linux-gnu/libpthread.a(pthread_create.o): in function `allocate_stack':
/build/glibc-RIFKjK/glibc-2.31/nptl/allocatestack.c:525: undefined reference to `_dl_stack_flags'
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /build/glibc-RIFKjK/glibc-2.31/nptl/allocatestack.c:525: undefined reference to `_dl_stack_flags'
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /build/glibc-RIFKjK/glibc-2.31/nptl/allocatestack.c:647: undefined reference to `_dl_stack_flags'
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /build/glibc-RIFKjK/glibc-2.31/nptl/allocatestack.c:647: undefined reference to `_dl_stack_flags'
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /home/mikeli/jetson/usr/lib/aarch64-linux-gnu/libpthread.a(nptl-init.o): in function `__pthread_initialize_minimal_internal':
/build/glibc-RIFKjK/glibc-2.31/nptl/nptl-init.c:335: undefined reference to `_dl_pagesize'
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /build/glibc-RIFKjK/glibc-2.31/nptl/nptl-init.c:335: undefined reference to `_dl_pagesize'
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /build/glibc-RIFKjK/glibc-2.31/nptl/nptl-init.c:344: undefined reference to `_dl_pagesize'
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /build/glibc-RIFKjK/glibc-2.31/nptl/nptl-init.c:360: undefined reference to `_dl_init_static_tls'
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /build/glibc-RIFKjK/glibc-2.31/nptl/nptl-init.c:362: undefined reference to `_dl_wait_lookup_done'
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /build/glibc-RIFKjK/glibc-2.31/nptl/nptl-init.c:360: undefined reference to `_dl_init_static_tls'
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /build/glibc-RIFKjK/glibc-2.31/nptl/nptl-init.c:362: undefined reference to `_dl_wait_lookup_done'
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /home/mikeli/jetson/usr/lib/aarch64-linux-gnu/libpthread.a(nptl-init.o): in function `__pthread_get_minstack':
/build/glibc-RIFKjK/glibc-2.31/nptl/nptl-init.c:393: undefined reference to `_dl_pagesize'
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /build/glibc-RIFKjK/glibc-2.31/nptl/nptl-init.c:393: undefined reference to `_dl_pagesize'
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /home/mikeli/jetson/usr/lib/aarch64-linux-gnu/libpthread.a(unwind.o): in function `_jmpbuf_sp':
/build/glibc-RIFKjK/glibc-2.31/nptl/../sysdeps/aarch64/jmpbuf-offsets.h:52: undefined reference to `__pointer_chk_guard_local'
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /build/glibc-RIFKjK/glibc-2.31/nptl/../sysdeps/aarch64/jmpbuf-offsets.h:52: undefined reference to `__pointer_chk_guard_local'
collect2: error: ld returned 1 exit status
make: *** [Makefile:53: jpeg_decode] Error 1

it generates undefined reference, how to deal with it?

Hi mike.li3

This undefined reference is caused from pthread library.

Could you help to try the following command and compile again?
$ cd ~/jetson/usr/lib/aarch64-linux-gnu
$ sudo ln -sf libpthread.so.0 libpthread.so

1 Like

Thanks Kevin! I can build the sample code now.
However, after building example, I can’t run it, it shows
/lib/ld-linux-aarch64.so.1: No such file or directory

could you figure out what happened here?

You told it how to link, now it also has to find libraries at run time. Is this the cross environment, or native to the Jetson? Instructions differ, but basically it needs an update to the LD_LIBRARY_PATH, or else a symbolic link added. If native, then the symbolic link is preferable ; if cross environment, then adjusting LD_LIBRARY_PATH is preferable. Whichever environment it is, what do you see for:

  • echo $LD_LIBRARY_PATH
  • ls -l /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
    (I say that because this is one standard location for finding that library)
1 Like

Since you cross compile, I assume you have copied the resulting binary to the target and run it there?

1 Like

HI mike.li3

The sample should be executed in target device for necessary libraries.
Please try to push compiled sample program to target device and run it there.

1 Like

thanks everyone. I can work cross compile on host computer and run it on target device

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