Qt 5.15.2 cross compile with different glibc and glibcxx on host and target
-
Hello. I have small problem. I need to compile Qt 5.15.2 on x86_64 under aarch64. I copied sysroot from raspberry, everything compiles, but there is a problem when running the program on raspberry.
pi@raspberrypi:~ $ ./testRasbperry ./testRasbperry: /lib/aarch64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /opt/Qt/qtbase/lib/libQt5Core.so.5) ./testRasbperry: /lib/aarch64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.28' not found (required by /opt/Qt/qtbase/lib/libQt5Core.so.5) ./testRasbperry: /lib/aarch64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /opt/Qt/qtbase/lib/libQt5Core.so.5)
On x86_64 used the following build commands Qt 5.15.2
Number one./qtbase/configure -release -no-gui -xplatform linux-aarch64-gnu-g++ -sysroot ~/RaspberryPi3B+/sysroot -prefix /opt/Qt/qtbase -extprefix ~/RaspberryPi3B+/buildQt -hostprefix ~/RaspberryPi3B+/buildQtTools -opensource -confirm-license -skip qtscript -skip qtwayland -skip qtwebengine -nomake tests -make libs -pkg-config -no-use-gold-linker
Numbet two
./qtbase/configure -release -no-gui -xplatform linux-aarch64-gnu-g++ -sysroot ~/RaspberryPi3B+/sysroot -prefix /opt/Qt/qtbase -extprefix ~/RaspberryPi3B+/buildQt -hostprefix ~/RaspberryPi3B+/buildQtTools -I ~/RaspberryPi3B+/sysroot/usr/include -L ~/RaspberryPi3B+/sysroot/lib -L ~/RaspberryPi3B+/sysroot/usr/lib -rpath -confirm-license -skip qtscript -skip qtwayland -skip qtwebengine -nomake tests -make libs -pkg-config -no-use-gold-linker
The result in both cases is the same, not the same glibc and glibcxx on host and target. Actually, what is the question, how to force the compiler to use the libraries from sysroot, and not the system ones. The host machine has aarch64-linux-gnu-g ++ - 10, so I changed the name of the compiler in the mkspec file. The option to download another compiler, I don't want, I need to force the existing compiler to look for libraries for Qt in sysroot.
Thanks in advance. -
@Kiruseni
your cross compile toolchain must contain (built against) the correct libc variant/version. -
@raven-worx
So is it impossible to cross compile Qt with aarch64-linux-gnu-10 on host with systems libs from sysroot? -
@Kiruseni
cant answer that.
But as always when you cross compile your toolchain must match your target system. The effectively used libc is not part of the sysroot but of the used cc toolchain.I simply assume your installed cross compile toolchain is too new for the target system.
When your host system doesn't provide a compatible toolchain you can built it yourself, using crosstool-ng
(for example see https://ilyas-hamadouche.medium.com/creating-a-cross-platform-toolchain-for-raspberry-pi-4-5c626d908b9d) -
@raven-worx
What is the meaning of the parameter "-gcc-sysroot" in qtbase/configure? -
@Kiruseni
what do you mean exactly?
what a sysroot is and what it is used for? if so there are plenty of resources on the web. -
@raven-worx
no$ ./configure --help | grep sysroot -sysroot <dir> ....... Set <dir> as the target sysroot -gcc-sysroot ......... With -sysroot, pass --sysroot to the compiler [yes]
if i use parametr -gcc-sysroot its mean take systems libs from sysroot or what?
-
@Kiruseni
honestly i dont know, i've never used nor seen this parameter until now actually.
I always used the -sysroot parameter so far.But it seems it is set automatically anyways. I assume it just means that the compiler handles the sysroot (which gcc is capable of)