Pisao sam o instalaciji Raspbiana na Raspberry Compute Module i postavljanju unakrsne kompilacije za QtCreator na Ubuntu 20.
Ovaj blog post je ažuriranje - u ovom trenutku - najnovije verzije 6.8 Qt, raspi OS Bookworm i Ubuntu 22.04 LTS.
Preduvjeti
Koristio sam sljedeći hardver i softver:
Raspberry Pi 4
raspi OS Bookworm, bez preporučenog softvera
Ubuntu 22.04 LTS
Qt 6.8
QtCreator 14.02
Bilješke
Ako imate prijenosno ili stolno računalo s dovoljno RAM-a i CPU jezgri, možete napraviti unakrsnu kompilaciju u virtualnom stroju. Ali stekao sam iskustvo da je izvorno računalo puno brže i proizvodi manje pogrešaka.
Pogledajte putanje datoteka i ip adrese u mojim primjerima koda i prilagodite ih svojim potrebama.
Otkrijte verzije gcc, ld i ldd. Izvorni kod iste verzije treba preuzeti za kasniju izradu unakrsnog kompajlera.
pi@raspberrypi:~ $ gcc --version
gcc (Debian 12.2.0-14) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
pi@raspberrypi:~ $ ld --version
GNU ld (GNU Binutils for Debian) 2.40
Copyright (C) 2023 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
pi@raspberrypi:~ $ ldd --version
ldd (Debian GLIBC 2.36-9+rpt2+deb12u8) 2.36
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
Dodajte sljedeći dio koda na kraj ~/.bashrc i ažurirajte promjene:
cd ~
wget https://github.com/Kitware/CMake/releases/download/v3.30.5/cmake-3.30.5.tar.gz
tar -xzvf cmake-3.30.5.tar.gz
cd cmake-3.30.5
./bootstrap
make -j$(nproc)
sudo make install
# Update PATH Environment Variable
which cmake
/usr/local/bin/cmake
export PATH=/usr/local/bin/cmake:$PATH
source ~/.bashrc
cmake --version
Izradite gcc kao unakrsni kompajler
Preuzmite potreban izvorni kod. Sljedeće naredbe trebali biste izmijeniti prema svojim potrebama. Za vrijeme kada napravim ovu stranicu, to su:
GCC 12.2.0
Binutils 2.40 (LD verzija)
GLIBC 2.36 (LDD verzija)
cd ~
mkdir gcc_all && cd gcc_all
wget https://ftpmirror.gnu.org/binutils/binutils-2.40.tar.bz2
wget https://ftpmirror.gnu.org/glibc/glibc-2.36.tar.bz2
wget https://ftpmirror.gnu.org/gcc/gcc-12.2.0/gcc-12.2.0.tar.gz
git clone --depth=1 https://github.com/raspberrypi/linux
tar xf binutils-2.40.tar.bz2
tar xf glibc-2.36.tar.bz2
tar xf gcc-12.2.0.tar.gz
rm *.tar.*
cd gcc-12.2.0
contrib/download_prerequisites
cd ~/gcc_all
cd linux
KERNEL=kernel7
make ARCH=arm64 INSTALL_HDR_PATH=/opt/cross-pi-gcc/aarch64-linux-gnu headers_install
Izgradite Binutils.
cd ~/gcc_all
mkdir build-binutils && cd build-binutils
../binutils-2.40/configure --prefix=/opt/cross-pi-gcc --target=aarch64-linux-gnu --with-arch=armv8 --disable-multilib
make -j 8
make install
Uredi gcc-12.2.0/libsanitizer/asan/asan_linux.cpp. Dodajte sljedeći dio koda.
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
Napravite djelomičnu verziju gcc-a.
cd ~/gcc_all
mkdir build-gcc && cd build-gcc
../gcc-12.2.0/configure --prefix=/opt/cross-pi-gcc --target=aarch64-linux-gnu --enable-languages=c,c++ --disable-multilib
make -j8 all-gcc
make install-gcc
Djelomično izgradite Glibc.
cd ~/gcc_all
mkdir build-glibc && cd build-glibc
../glibc-2.36/configure --prefix=/opt/cross-pi-gcc/aarch64-linux-gnu --build=$MACHTYPE --host=aarch64-linux-gnu --target=aarch64-linux-gnu --with-headers=/opt/cross-pi-gcc/aarch64-linux-gnu/include --disable-multilib libc_cv_forced_unwind=yes
make install-bootstrap-headers=yes install-headers
make -j8 csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o /opt/cross-pi-gcc/aarch64-linux-gnu/lib
aarch64-linux-gnu-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o /opt/cross-pi-gcc/aarch64-linux-gnu/lib/libc.so
touch /opt/cross-pi-gcc/aarch64-linux-gnu/include/gnu/stubs.h
Natrag na gcc.
cd ~/gcc_all/build-gcc
make -j8 all-target-libgcc
make install-target-libgcc
Završite izgradnju glibc.
cd ~/gcc_all/build-glibc
make -j8
make install
Završite izgradnju gcc.
cd ~/gcc_all/build-gcc
make -j8
make install
U ovom trenutku imamo potpuni lanac alata za unakrsni kompajler s gcc-om. Mapa gcc_all više nije potrebna. Možete ga izbrisati.</:code19:></:code18:></:code17:></:code16:></:code15:></:code14:></:code13:></:code12:></:code11:></:code10:></:code9:></:code8:></:code7:>
Zgrada Qt6
Postoje dvije mogućnosti za izgradnju Qt6. Postoji "single" (https://download.qt.io/official_releases/qt/6.8/6.8.0/single/qt-everywhere-src-6.8.0.tar.xz) verzija za preuzimanje, koja sadrži qtbase i sve podmodule. Ovo je vrlo teška stvar i treba puno snage i vremena da se sastavi.
Moja preporuka je, da qtbase sastavite kao osnovu i nakon toga sastavite samo svaki podmodul koji vam je potreban zasebno.
Napravite mape za sysroot i qt6. Kreiram ove mape u svom workspace/qt-rpi-cross-compilation direktoriju.
cd ~/workspace/qt-rpi-cross-compilation/qt6/src
wget https://download.qt.io/official_releases/qt/6.8/6.8.0/submodules/qtbase-everywhere-src-6.8.0.tar.xz
tar xf qtbase-everywhere-src-6.8.0.tar.xz
Stvorite datoteku pod nazivom toolchain.cmake u ~/workspace/qt-rpi-cross-compilation/qt6.
Morate prilagoditi redak "set(TARGET_SYSROOT /home/factory/workspace/qt-rpi-cross-compilation/rpi-sysroot)" svom okruženju.
Ako kreirate projekt u QtCreatoru, morate prilagoditi konfiguraciju "Run". U "Environment" morate dodati:
-LD_LIBRARY_PATH=:/usr/local/qt6/lib/
Dodavanje Qt podmodula
Dodajte QML modul
Preuzmite izvorne kodove:
cd ~/workspace/qt-rpi-cross-compilation/qt6/src
wget https://download.qt.io/official_releases/qt/6.8/6.8.0/submodules/qtshadertools-everywhere-src-6.8.0.tar.xz
tar xf qtshadertools-everywhere-src-6.8.0.tar.xz
wget https://download.qt.io/official_releases/qt/6.8/6.8.0/submodules/qtdeclarative-everywhere-src-6.8.0.tar.xz
tar xf qtdeclarative-everywhere-src-6.8.0.tar.xz
Ovisnosti morate provjeriti na ~/workspace/qt-rpi-cross-compilation/qt6/src/qtdeclarative-everywhere-src-6.8.0/dependencies.yaml i ~/workspace/qt-rpi-cross-compilation/qt6/src/qtshadertools-everywhere-src-6.8.0/dependencies.yaml.
Prvo provjerite trebaju li se izgraditi i instalirati potrebni moduli.