Qt6 Raspberry Pi cross compliation error.
-
Hi,
I tried to cross compile qt6 programs on Ubuntu virtual machine for Raspberry Pi 4B following this tutorial:[https://wiki.qt.io/Cross-Compile_Qt_6_for_Raspberry_Pi](link url)
However, I came aross the following list of errors:
:-1: error: /home/shuchun/RaspberryPi/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `_dl_make_stack_executable@GLIBC_PRIVATE' :-1: error: /home/shuchun/RaspberryPi/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_dlclose@GLIBC_PRIVATE' :-1: error: /home/shuchun/RaspberryPi/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_dlopen_mode@GLIBC_PRIVATE' :-1: error: /home/shuchun/RaspberryPi/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_longjmp@GLIBC_PRIVATE' :-1: error: /home/shuchun/RaspberryPi/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_allocate_rtsig_private@GLIBC_PRIVATE' :-1: error: /home/shuchun/RaspberryPi/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_thread_freeres@GLIBC_PRIVATE' :-1: error: /home/shuchun/RaspberryPi/rpi-sysroot/lib/aarch64-linux-gnu/libdl.so.2: undefined reference to `_dl_addr@GLIBC_PRIVATE' :-1: error: /home/shuchun/RaspberryPi/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_pthread_init@GLIBC_PRIVATE' :-1: error: /home/shuchun/RaspberryPi/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_current_sigrtmin_private@GLIBC_PRIVATE' :-1: error: /home/shuchun/RaspberryPi/rpi-sysroot/lib/aarch64-linux-gnu/libdl.so.2: undefined reference to `_dl_sym@GLIBC_PRIVATE' :-1: error: /home/shuchun/RaspberryPi/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_dlsym@GLIBC_PRIVATE' :-1: error: /home/shuchun/RaspberryPi/rpi-sysroot/lib/aarch64-linux-gnu/libpthread.so.0: undefined reference to `__libc_current_sigrtmax_private@GLIBC_PRIVATE' :-1: error: /home/shuchun/RaspberryPi/rpi-sysroot/lib/aarch64-linux-gnu/libdl.so.2: undefined reference to `_dl_vsym@GLIBC_PRIVATE' :-1: error: collect2: error: ld returned 1 exit status :-1: error: ninja: build stopped: subcommand failed.
I tried both sympinks and sysroot-relativelinks.py, but they didn't resolve the issue.
Also, the tutorial create all folders under home while I created an additional RaspberryPi folder.
I also disabled -opengl es2 -device linux-rasp-pi4-aarch64 in configure. And I disabled dbus by adding -DFEATURE_dbus=OFF
Any help is super welcome
-
Hi @shuchun ,
Did you find any solution?
-
Same issue here.
I've alse asked in the Discord server in #build-systems if someone can help. -
My output of
cat /etc/os-release
on the Raspberry Pi 4:PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" NAME="Debian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
-
I'm suspecting it's a GCC version mixup (RPI version = 10 and host version = 11). I'm now going to test with a VM of Ubuntu 20.04 using the official guide on: https://wiki.qt.io/Cross-Compile_Qt_6_for_Raspberry_Pi
-
I have the same problem too.
My Ubuntu 22.04 arm-linux-gnueabihf-gcc version 11.2.0
Raspberry Pi arm-linux-gnueabihf-gcc version 8.3.0
I don't know how to solve.:-1: error: /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libpthread.so.0: undefined reference to `_dl_make_stack_executable@GLIBC_PRIVATE' :-1: error: /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libpthread.so.0: undefined reference to `__nanosleep_nocancel@GLIBC_PRIVATE' :-1: error: /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libpthread.so.0: undefined reference to `__libc_dlclose@GLIBC_PRIVATE' :-1: error: /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libpthread.so.0: undefined reference to `__libc_dlopen_mode@GLIBC_PRIVATE' :-1: error: /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libpthread.so.0: undefined reference to `__libc_longjmp@GLIBC_PRIVATE' :-1: error: /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libpthread.so.0: undefined reference to `__libc_vfork@GLIBC_PRIVATE' :-1: error: /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libpthread.so.0: undefined reference to `__libc_allocate_rtsig_private@GLIBC_PRIVATE' :-1: error: /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libpthread.so.0: undefined reference to `__libc_thread_freeres@GLIBC_PRIVATE' :-1: error: /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libpthread.so.0: undefined reference to `__pause_nocancel@GLIBC_PRIVATE' :-1: error: /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libpthread.so.0: undefined reference to `__libc_pthread_init@GLIBC_PRIVATE' :-1: error: /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libpthread.so.0: undefined reference to `__libc_current_sigrtmin_private@GLIBC_PRIVATE' :-1: error: /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libpthread.so.0: undefined reference to `__libc_dlsym@GLIBC_PRIVATE' :-1: error: /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libpthread.so.0: undefined reference to `__libc_current_sigrtmax_private@GLIBC_PRIVATE' :-1: error: collect2: error: ld returned 1 exit status
-
Downgrading to an Ubuntu 20.04 based distro solved this first issue for me but unfortunately, I got a second issue out of it:
FAILED: lib/libQt6DBus.so.6.3.0 src/dbus/DBus.version /home/dmg/toolchain/qt-build/qt-aarch64-linux-gnu/src/dbus/DBus.version cd /home/dmg/toolchain/qt-build/qt/qtbase-everywhere-src-6.3.0/src/dbus && /usr/bin/perl /home/dmg/toolchain/qt-build/qt/qtbase-everywhere-src-6.3.0/mkspecs/features/data/unix/findclasslist.pl < /home/dmg/toolchain/qt-build/qt-aarch64-linux-gnu/src/dbus/DBus.version.in > /home/dmg/toolchain/qt-build/qt-aarch64-linux-gnu/src/dbus/DBus.version && cd /home/dmg/toolchain/qt-build/qt-aarch64-linux-gnu && /usr/bin/aarch64-linux-gnu-g++ --sysroot=/home/dmg/toolchain/rpi-sysroot -fPIC -I/home/dmg/toolchain/rpi-sysroot/usr/include -pipe -O2 -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -lpthread -Wl,--version-script,/home/dmg/toolchain/qt-build/qt-aarch64-linux-gnu/src/dbus/DBus.version -Wl,--no-undefined -Wl,--enable-new-dtags -shared -Wl,-soname,libQt6DBus.so.6 -o lib/libQt6DBus.so.6.3.0 src/dbus/CMakeFiles/DBus.dir/DBus_autogen/mocs_compilation.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbus_symbols.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusabstractadaptor.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusabstractinterface.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusargument.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusconnection.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusconnectioninterface.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbuscontext.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbuserror.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusextratypes.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusintegrator.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusinterface.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusinternalfilters.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusintrospection.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusmessage.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusmetaobject.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusmetatype.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusmisc.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbuspendingcall.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbuspendingreply.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusreply.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusserver.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusservicewatcher.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusunixfiledescriptor.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusutil.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusvirtualobject.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusxmlgenerator.cpp.o src/dbus/CMakeFiles/DBus.dir/qdbusxmlparser.cpp.o -Wl,-rpath,/home/dmg/toolchain/rpi-sysroot:/home/dmg/toolchain/qt-build/qt-aarch64-linux-gnu/lib: /home/dmg/toolchain/rpi-sysroot/lib/aarch64-linux-gnu/libdbus-1.a lib/libQt6Core.so.6.3.0 -lpthread && : /usr/aarch64-linux-gnu/bin/ld: /home/dmg/toolchain/rpi-sysroot/lib/aarch64-linux-gnu/libdbus-1.a(libdbus_1_la-dbus-message.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `dbus_message_unref' which may bind externally can not be used when making a shared object; recompile with -fPIC /home/dmg/toolchain/rpi-sysroot/lib/aarch64-linux-gnu/libdbus-1.a(libdbus_1_la-dbus-message.o): in function `_dbus_message_loader_unref': (.text+0x59d8): dangerous relocation: unsupported relocation /usr/aarch64-linux-gnu/bin/ld: /home/dmg/toolchain/rpi-sysroot/lib/aarch64-linux-gnu/libdbus-1.a(libdbus_1_la-dbus-timeout.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_dbus_timeout_unref' which may bind externally can not be used when making a shared object; recompile with -fPIC /home/dmg/toolchain/rpi-sysroot/lib/aarch64-linux-gnu/libdbus-1.a(libdbus_1_la-dbus-timeout.o): in function `_dbus_timeout_list_free': (.text+0x130): dangerous relocation: unsupported relocation /usr/aarch64-linux-gnu/bin/ld: /home/dmg/toolchain/rpi-sysroot/lib/aarch64-linux-gnu/libdbus-1.a(libdbus_1_la-dbus-watch.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_dbus_watch_unref' which may bind externally can not be used when making a shared object; recompile with -fPIC /home/dmg/toolchain/rpi-sysroot/lib/aarch64-linux-gnu/libdbus-1.a(libdbus_1_la-dbus-watch.o): in function `_dbus_watch_list_free': (.text+0x1b0): dangerous relocation: unsupported relocation /usr/aarch64-linux-gnu/bin/ld: /home/dmg/toolchain/rpi-sysroot/lib/aarch64-linux-gnu/libdbus-1.a(libdbus_1_la-dbus-sysdeps-unix.o): in function `_dbus_listen_systemd_sockets': (.text+0x204c): undefined reference to `sd_listen_fds' /usr/aarch64-linux-gnu/bin/ld: (.text+0x2090): undefined reference to `sd_is_socket' /usr/aarch64-linux-gnu/bin/ld: /home/dmg/toolchain/rpi-sysroot/lib/aarch64-linux-gnu/libdbus-1.a(libdbus_1_la-dbus-userdb.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_dbus_group_info_unref' which may bind externally can not be used when making a shared object; recompile with -fPIC /home/dmg/toolchain/rpi-sysroot/lib/aarch64-linux-gnu/libdbus-1.a(libdbus_1_la-dbus-userdb.o): in function `_dbus_user_database_new': (.text+0x4e8): dangerous relocation: unsupported relocation collect2: error: ld returned 1 exit status
-
@shuchun Temporary solution:
I've fixed the latest issue. The last issue was due to my rpi-sysroot symlink repair not done correctly.
Make sure with fixing the symlinks, you use the following commands:$ wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py $ chmod +x sysroot-relativelinks.py $ python3 sysroot-relativelinks.py $TARGET_SYSROOT
The temporary solution on the original issue for me was downgrading the host to an Ubuntu 20.04 based distro.
Looks like we'll have to deal with the older distro untill the Qt devs solve this issue with the newer 22.04 version.
I suspect that the issue is caused by a mismatch between GCC (and gLibC) versions on the Pi and the Host but I'm not sure about that. Alternatively, you can try to update the GCC and GLibC versions on the Raspberry Pi. -
Hello,
I also came across this problem. I tried compiling everything with the GCC 10 version which is installed on my RPI. I will give the older Linux version a try using an old Notebook. I am also not very deep into compiler dependencies, so hopefully this also works for me.
BR
-
@rickiewars I have encountered all the problems mentioned in the thread. Your posts were very helpful, I managed to compile and run QT on my RPI4. The sysroot-relativelinks.py fixed the problem with dbus and upgrading the GCC on my rpi to gcc-11, solved the problem with undefined references.
-
Same errors.
I used
symlinks -rc rpi-sysroot
Is sysroot-relativelinks.py different so that I need to use it instead?
Kumi,
How does changing the compiler on the rpi help? That won't change the libraries on the Bullseye distribution that seem to be the issue.
Thanks!
-
There does seem to be a difference in what the symlinks (that's built into Ubuntu) does versus the sysroots-relativelinks.py script.
I deleted all the sysroot files, and redid the rsync. Deleted everything in the build folders and redid the configure.
It's still compiling---3000 out of 8066 files. I'm pretty sure that's beyond where it was failing for dbus issues.
I guess I'll get to the unresolved references issue. Is the theory that the libc needs to be rebuilt with a compatible compiler on the rpi, then rsync'ed back to the host machine? Obviously, nothing you do on the rpi will help the build on the host--unless you copy files over from the rpi into sysroot.
Right?
-
Yes, same place.
Down to the link phase, now get the unresolved externals.
I tried /usr/bin/aarch64-linux-gnu-gcc-11 and -9. (and same g++). My rpi Bullseye has gcc and g++ 10.2.1 20210110.
So, one gcc release earlier and one later.
Anyone have a cross-compiler known to work?
-
I've tried gcc-9, -10, and -11. I get the same unresolved externals at link time like this:
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' /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/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_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/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/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 `__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/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_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_vsym@GLIBC_PRIVATE' collect2: error: ld returned 1 exit status
You said:
Downgrading to an Ubuntu 20.04 based distro solved this first issue for me
Do you know what gcc and g++ compiler you used? If I was sure that 20.04 would resolve, I'd start over. But, that's a lot of work and I think only the toolchain matters.
Thanks!
-
@Dane-0 I had the same problem with Ubuntu 22.04 and Qt6. Using gcc-11 on raspberry pi solved the issue. However, you need to cross compile the gcc-11 for the raspberry pi. To do so, first you need to set up a cross compiler using the same version of glibc, binutils, and gcc that you have on your raspberry pi system. This link is exactly what you need to do:
https://solarianprogrammer.com/2018/05/06/building-gcc-cross-compiler-raspberry-pi/Follow the instruction in this tutorial exactly, and finally add these paths to your LD_LIBRARY_PATH variable on your pi:
/path/to/gcc-11/lib
/path/to/gcc-11/lib64I hope this will help you.
-
Is there any progress on this? Did anyone solve this? I am having the same issue. I am using the Cross-Compile Qt6 for Raspberry Pi documentation. Host Ubuntu 22.04, Target Raspberry Pi Bookworm. I can Build for the Host, and can also configure it for the Target without issues, but when I try to build it for target I always get the issue
FAILED qtbase/libQt6DBus.so.6.5.3
. I am using aarch64-linux-gnu-g++-11.ninja --version
1.10.1
cmake --version
cmake version 3.28.20231020-g35c7e23 (self build)EDIT:
On my Raspberry I have gcc --version -> 12.2.0. Maybe I should use the version 12 cross compiler as well. -
I'm aware this is ancient history but I was running into this problem as well (I've corrected it) and feel it necessary to add a bit more context and my analysis of what I think is happening. Tl;dr I was able to correct the aforementioned error by running the
sysroot-relativesymlinks.py
script mentioned above, re-running the configure, and rebuilding.As noted previously,
symlinks
doesn't quite fix everything and I also had to use the Python symlink script. What I noticed, though, after runningsymlinks
the first time is that a few shared libraries (such as Dbus) were not being correctly re-linked. Specifically:aaron@AUSTIN:~$ ls -l rpi-sysroot/lib/aarch64-linux-gnu/libdbus* -rw-r--r-- 1 aaron aaron 785514 Sep 16 2023 rpi-sysroot/lib/aarch64-linux-gnu/libdbus-1.a lrwxrwxrwx 1 aaron aaron 42 Sep 16 2023 rpi-sysroot/lib/aarch64-linux-gnu/libdbus-1.so -> /lib/aarch64-linux-gnu/libdbus-1.so.3.32.4 lrwxrwxrwx 1 aaron aaron 19 Sep 16 2023 rpi-sysroot/lib/aarch64-linux-gnu/libdbus-1.so.3 -> libdbus-1.so.3.32.4 -rw-r--r-- 1 aaron aaron 395336 Sep 16 2023 rpi-sysroot/lib/aarch64-linux-gnu/libdbus-1.so.3.32.4
Notice how
libdbus-1.so
is still pointing to my system's (aarch64) version of libdbus, which also did not exist, since my system is x86_64 -- so the link itself was bad. So just a reminder to ensure that all of the links in your sysroot do not point to anything outside of that sysroot.Hopefully this helps any Googler in the future.