Issues setting up GCC 8.3.0 Cross Compiler to compile Qt 5.15 for Raspberry Pi 4
-
Hi!
I'm trying to cross-compile Qt 5.15.0 for a Raspberry Pi 4 and I'm having trouble with the toolchain.
I'm very new to cross-compiling (and compilation on Linux in general), so any advice would be appreciated.My Setup:
Raspberry Pi 4: Pi OS (32-bit) May 2020 Version (Kernel 4.19)Host: Ubuntu 20.04 LTS Running in VMWare Player
I've been mainly following these two guides:
- https://wapel.de/?p=641 (mainly following this - make failed due to an error related to C++11 not being enabled)
- https://www.interelectronix.com/de/qt-auf-dem-raspberry-pi-4.html (followed this to change the gcc compiler 8.3.0 to try fix above issue)
These are the key steps:
- Synced the folder structure using rsync
- Adjusted symlinks to be relative
- Downloaded the Qt 5.15 source files
- Downloaded the toolchain
i. Initially downloaded from: https://github.com/raspberrypi/tools (GCC version was 4.7 or 4.8 I think)
ii. After issues, downloaded the GCC Cross Compiler Toolchain(Buster) 8.3.0 from here: https://github.com/abhiTronix/raspberry-pi-cross-compilers#d-toolchain-binaries-downloads
I extracted the toolchain inside the tools folder (folder structure shown below).
I used these commands to modify the source files to allow me to use the new toolchain:
cp -R qt-everywhere-src-5.15.0/qtbase/mkspecs/linux-arm-gnueabi-g++ qt-everywhere-src-5.15.0/qtbase/mkspecs/linux-arm-gnueabihf-g++ sed -i -e 's/arm-linux-gnueabi-/arm-linux-gnueabihf-/g' qt-everywhere-src-5.15.0/qtbase/mkspecs/linux-arm-gnueabihf-g++/qmake.conf
I created a build directory outside the source folder.
This is what the folder structure roughly looked like on my Ubuntu VM:
raspi
├── build
├── qt-everywhere-src-5.15.0
│ ├── [Qt source files]
├── sysroot
│ ├── lib
│ ├── opt
│ └── usr
└── tools
└── cross-pi-gcc-8.3.0-2
│ ├── arm-linux-gnueabihf
│ ├── bin
│ ├── include
│ ├── lib
│ ├── libexec
│ └── shareNow my issue is with the configure step. I run the following command from within the build folder to configure my build:
../qt-everywhere-src-5.15.0/configure -release -opengl es2 -device linux-rasp-pi4-v3d-g++ -device-option CROSS_COMPILE=~/raspi/tools/cross-pi-gcc-8.3.0-2/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -no-use-gold-linker -v
However, this fails. This is what the last few lines of my config.log file looks like:
> /home/user_name/raspi/tools/cross-pi-gcc-8.3.0-2/bin/arm-linux-gnueabihf-g++ -mfloat-abi=hard --sysroot=/home/user_name/raspi/sysroot -Wl,-O1 -Wl,-rpath-link,/home/user_name/raspi/sysroot/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/home/user_name/raspi/sysroot/lib/arm-linux-gnueabihf -o verifyspec verifyspec.o > /home/user_name/raspi/tools/cross-pi-gcc-8.3.0-2/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find crt1.o: No such file or directory > /home/user_name/raspi/tools/cross-pi-gcc-8.3.0-2/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find crti.o: No such file or directory > /home/user_name/raspi/tools/cross-pi-gcc-8.3.0-2/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lm > collect2: error: ld returned 1 exit status > make: *** [Makefile:68: verifyspec] Error 1
From what I can understand, it's having issues using the gcc toolchain that I downloaded. When I tried using the tool chain I mentioned in step 4i above, configure worked perfectly, I just had issues with the build. I'm guessing I've missed a key step in configuring the GCC 8.3.0 cross-compiler for this project.
Could anyone point me in the right direction to fix this?
Thanks!
-
I managed to solve this issue by following this guide:
https://github.com/UvinduW/Cross-Compiling-Qt-for-Raspberry-Pi-4I think the cross-compiler I downloaded above had issues using my sysroot directory.
The instructions linked above use a linaro compiler (albeit an older one) and it compiled Qt 5.15 successfully. -
Hi author here,
Now there's a dedicated guide available to follow for cross-compiling latest QT for any Raspberry Pi Model or Version with mentioned GCC toolchains:
https://github.com/abhiTronix/raspberry-pi-cross-compilers/blob/master/QT_build_instructions.md