Niliandika juu ya usakinishaji wa Raspbian kwenye Moduli ya Raspberry Compute na usanidi mkusanyiko wa msalaba kwa QtCreator kwenye Ubuntu 20.
Makala hii ni sasisho kwa - kwa wakati huu - toleo jipya zaidi la 6.8 la Qt, raspi OS Bookworm na Ubuntu 22.04 LTS.
Mahitaji ya awali
Nilitumia programu ngumu na ngumu zifuatazo:
*Raspberry Pi 4
*raspi OS Bookworm, bila programu iliyopendekezwa
*Ubuntu 22.04 LTS
*Qt 6.8
*QtCreator 14.02
Madokezo
Ikiwa una kompyuta ndogo au kompyuta ya mezani iliyo na cores za kutosha za RAM na CPU, unaweza kufanya mkusanyiko wa msalaba kwenye mashine pepe. Lakini nilifanya uzoefu, kwamba kompyuta ya asili ni haraka sana na hutoa makosa kidogo.
Angalia njia za faili na anwani za ip katika mifano yangu ya nambari na uyarekebishe kwa mahitaji yako.
Kugundua matoleo ya gcc, ld na ldd. Msimbo wa chanzo wa toleo moja unapaswa kupakuliwa ili kujenga mkusanyaji msalaba baadaye.
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.
Ambatisha kipande cha msimbo kinachofuata hadi mwisho wa ~/.bashrc na usasishe mabadiliko:
Jenga toleo la hivi karibuni la cmake kutoka kwa chanzo:
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
Jenga gcc kama mkusanyaji wa msalaba
Pakua msimbo wa chanzo muhimu. Unapaswa kurekebisha amri zifuatazo kwa mahitaji yako. Kwa wakati mimi kufanya ukurasa huu, wao ni:
GCC 12.2.0
Binutils 2.40 (toleo la LD)
glibc 2.36 (toleo la LDD)
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
Nakili vichwa vya kernel kwenye folda iliyo hapo juu.
cd ~/gcc_all
cd linux
KERNEL=kernel7
make ARCH=arm64 INSTALL_HDR_PATH=/opt/cross-pi-gcc/aarch64-linux-gnu headers_install
Kujenga 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
Hariri gcc-12.2.0/libsanitizer/asan/asan_linux.cpp. Ongeza kipande cha msimbo ufuatao.
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
Fanya ujenzi wa sehemu ya gcc.
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
Kwa kiasi fulani kujenga 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
Rudi kwa gcc.
cd ~/gcc_all/build-gcc
make -j8 all-target-libgcc
make install-target-libgcc
Kumaliza ujenzi wa glibc.
cd ~/gcc_all/build-glibc
make -j8
make install
Kumaliza ujenzi wa gcc.
cd ~/gcc_all/build-gcc
make -j8
make install
Kwa wakati huu, tuna mnyororo kamili wa zana ya kukusanya msalaba na gcc. Folda gcc_all haiitaji tena. Unaweza kuifuta.</:code19:></:code18:></:code17:></:code16:></:code15:></:code14:></:code13:></:code12:></:code11:></:code10:></:code9:></:code8:></:code7:>
Ujenzi wa Qt6
Kuna uwezekano wa kujenga Qt6. Kuna toleo la "single" (https://download.qt.io/official_releases/qt/6.8/6.8.0/single/qt-everywhere-src-6.8.0.tar.xz) la kupakua, ambalo lina qtbase na submodules zote. Hii ni mambo mazito sana na inahitaji nguvu nyingi na wakati wa kuikusanya.
Pendekezo langu ni, kukusanya qtbase kama msingi na baadaye kukusanya tu kila submodule unahitaji tofauti.
Tengeneza folda kwa sysroot na qt6. Ninaunda folda hizi kwenye nafasi yangu ya kazi / saraka ya qt-rpi-cross-compilation.
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
Unda faili inayoitwa toolchain.cmake katika ~/workspace/qt-rpi-cross-compilation/qt6.
Unahitaji kurekebisha mstari "seti(TARGET_SYSROOT /home/factory/workspace/qt-rpi-cross-compilation/rpi-sysroot)" kwa mazingira yako.
Ikiwa unaunda mradi katika QtCreator, lazima urekebishe usanidi wa "Run". Kwa "Environment" unahitaji kuongeza:
-LD_LIBRARY_PATH=:/usr/local/qt6/lib/
Ongeza Submodules ya Qt
Ongeza moduli ya QML
Pakua misimbo ya chanzo:
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
Lazima uangalie utegemezi katika ~/workspace/qt-rpi-cross-compilation/qt6/src/qtdeclarative-everywhere-src-6.8.0/dependencies.yaml na ~/workspace/qt-rpi-cross-compilation/qt6/src/qtshadertools-everywhere-src-6.8.0/dependencies.yaml.
Hakikisha moduli zinazohitajika zinapaswa kujengwa na kusakinishwa kwanza.