Cross compiling qt6 for RPI 64 bit (aarch64)
I'm trying to cross compile qt6 for Bullseye on an Ubuntu 22.04.
Everything compiles, but I seeing unresolved externals that (I think) should be in clib:
Code:
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: /home/dave/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_dlopen_mode@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: /home/dave/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_current_sigrtmin_private@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: /home/dave/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_dlclose@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: /home/dave/rpi-sysroot/lib/aarch64-linux-gnu/libdl.so.2: undefined reference to `_dl_sym@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: /home/dave/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_longjmp@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: /home/dave/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_allocate_rtsig_private@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: /home/dave/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_thread_freeres@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: /home/dave/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_dlsym@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: /home/dave/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_current_sigrtmax_private@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: /home/dave/rpi-sysroot/lib/aarch64-linux-gnu/libdl.so.2: undefined reference to `_dl_addr@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: /home/dave/rpi-sysroot/lib/aarch64-linux-gnu/libdl.so.2: undefined reference to `_dl_vsym@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: /home/dave/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_pthread_init@GLIBC_PRIVATE'
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld: /home/dave/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `_dl_make_stack_executable@GLIBC_PRIVATE'
Another forum has a post saying that this is probably due to a mismatch between the cross-compiler on Ubuntu and the rpi.
Here's what's on the pi:
Code:
pi@raspberrypi:~ $ g++ --version
g++ (Debian 10.2.1-6) 10.2.1 20210110
Here's what I have in the "toolchain.cmake":
Code:
set(CMAKE_C_COMPILER /usr/bin/aarch64-linux-gnu-gcc-10)
set(CMAKE_CXX_COMPILER /usr/bin/aarch64-linux-gnu-g++-10)
I've also tried the -9 and -11 versions of gcc and g++, but get the same errors.
The poster said he solved the error by downgrading the Ubuntu host to 20.x. I'd do that, if I thought it would work, but seems like I should be able to use the same cross-compiler.
Three questions:
1) Are the unresolved externals indeed (likely) due to an incompatible C run time used by the cross-compiler?
2) What cross compiler toolchain should I use?
3) What cross compiler is available for cross-compiling on Ubuntu 20 (if any) that's not on Ubuntu 22?
Here's the guide I've been using:
https://wiki.qt.io/Cross-Compile_Qt_6_for_Raspberry_Pi
Thanks!
Re: Cross compiling qt6 for RPI 64 bit (aarch64)
I do not know if this is the cause, but unlike in Windows with Microsoft compilers, the order of modules specified in the linker command matters in linux / gcc. If any module depends on references defined in another module, the module that resolves the dependency must come after the module that needs it on the command line.
I pounded my head on the wall for some time trying to get something to link before I learned this nugget.
Re: Cross compiling qt6 for RPI 64 bit (aarch64)
Quote:
Originally Posted by
d_stranz
I do not know if this is the cause, but unlike in Windows with Microsoft compilers, the order of modules specified in the linker command matters in linux / gcc. If any module depends on references defined in another module, the module that resolves the dependency must come after the module that needs it on the command line.
I pounded my head on the wall for some time trying to get something to link before I learned this nugget.
I don't understand why, but starting over with host Ubuntu 20.04 works fine.
Someone posted that on another forum, but that didn't make sense to me. And, since it takes a LONG time to recompile everything that's needed to get to the link stage, I was hesitant to even try. Seemed like all I should need was the right toolchain.
But, spent a couple of days trying various gcc and g++ versions, including the version on the target (Bullseye aarch rpi) and the version on Ubuntu 20.04 on the Ubuntu 22 host.
I followed the guide exactly--on Ubuntu 22 there were several issues I was able to work-around just to get to the "show-stopper" at link time.
On Ubuntu 20.04, worked first time, zero issues!
Go figure.