Wenn "raspberrypi.local" nicht funktioniert, nutze bitte die IP Adresse der Raspberry Pi
Raspberry Pi vorbereiten
Bitte nutze ein neues raspbian (2018-06-27, lite funktioniert eventuell, nicht getestet) image
Update
Die Datei /etc/apt/sources.list öffnen und in der Zeile für deb-src das Kommentar entfernen
Code: Select all
sudo nano /etc/apt/sources.list
Code: Select all
sudo apt-get update
sudo apt-get dist-upgrade
sudo reboot
Code: Select all
sudo rpi-update
sudo reboot
Code: Select all
sudo apt-get build-dep qt5-qmake
sudo apt-get build-dep libqt5gui5
sudo apt-get build-dep libqt5webengine-data
sudo apt-get build-dep libqt5webkit5
sudo apt-get install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0 gdbserver
Code: Select all
sudo mkdir /usr/local/qt5pi
sudo chown -R pi:pi /usr/local/qt5pi
Linux Host vorbereiten (zum Beispiel Ubuntu x64)
Update
Code: Select all
sudo apt-get update
sudo apt-get -y upgrade
Code: Select all
sudo apt-get install gcc git bison python gperf pkg-config gdb-multiarch
ssh public key erstellen
Code: Select all
ssh-keygen -t rsa -C pi@raspberrypi.local -N "" -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub | ssh -o StrictHostKeyChecking=no pi@raspberrypi.local "mkdir -p .ssh && chmod 700 .ssh && cat >> .ssh/authorized_keys"
Code: Select all
sudo mkdir /opt/qt5pi
sudo chown 1000:1000 /opt/qt5pi
cd /opt/qt5pi
Toolchain herunterladen
Code: Select all
git clone https://github.com/raspberrypi/tools
Code: Select all
nano ~/.bashrc
Code: Select all
export PATH=$PATH:/opt/qt5pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin
Wenn du einen 32Bit Host nutzt, verwende bitte dieses toolchain: /opt/qt5pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin
Qt Sources downloaden
Code: Select all
wget http://download.qt.io/official_releases/qt/5.10/5.10.1/single/qt-everywhere-src-5.10.1.tar.xz
Code: Select all
tar xf qt-everywhere-src-5.10.1.tar.xz
Code: Select all
cp -R qt-everywhere-src-5.10.1/qtbase/mkspecs/linux-arm-gnueabi-g++ qt-everywhere-src-5.10.1/qtbase/mkspecs/linux-arm-gnueabihf-g++
sed -i -e 's/arm-linux-gnueabi-/arm-linux-gnueabihf-/g' qt-everywhere-src-5.10.1/qtbase/mkspecs/linux-arm-gnueabihf-g++/qmake.conf
Code: Select all
mkdir sysroot sysroot/usr sysroot/opt
rsync -avz pi@raspberrypi.local:/lib sysroot
rsync -avz pi@raspberrypi.local:/usr/include sysroot/usr
rsync -avz pi@raspberrypi.local:/usr/lib sysroot/usr
rsync -avz pi@raspberrypi.local:/opt/vc sysroot/opt
Korrekte symlinks für "fehlende" Bibliotheken erstellen
Code: Select all
mv sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0 sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0_backup
ln -s sysroot/opt/vc/lib/libEGL.so sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0
Code: Select all
mv sysroot/usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0 sysroot/usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0_backup
ln -s sysroot/opt/vc/lib/libGLESv2.so sysroot/usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0
Code: Select all
ln -s sysroot/opt/vc/lib/libEGL.so sysroot/opt/vc/lib/libEGL.so.1
Code: Select all
ln -s sysroot/opt/vc/lib/libGLESv2.so sysroot/opt/vc/lib/libGLESv2.so.2
Absolute symlinks in relative symlinks konvertieren
Code: Select all
wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py
chmod +x sysroot-relativelinks.py
./sysroot-relativelinks.py sysroot
Build Verzeichnis erstellen
Code: Select all
mkdir qt5build
Code: Select all
cd qt5build
../qt-everywhere-src-5.10.1/configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /opt/qt5pi/sysroot -prefix /usr/local/qt5pi -opensource -confirm-license -no-gbm -skip qtscript -nomake tests -nomake examples -make libs -pkg-config -no-use-gold-linker -v 2>&1 | tee ../configure.log
Für jede Generation von Raspberry Pi, muss man die Option -device ändern
Raspberry Pi 1 (+ Zero and Zero W): -device linux-rasp-pi-g++
Raspberry Pi 2: -device linux-rasp-pi2-g++
Raspberry Pi 3: -device linux-rasp-pi3-g++
Raspberry Pi 3 with VC4 driver: -device linux-rasp-pi3-vc4-g++
Make
Code: Select all
make 2>&1 | tee ../make.log
make install 2>&1 | tee ../make_install.log
Code: Select all
cd /opt/qt5pi
rsync -avz sysroot/usr/local/qt5pi pi@raspberrypi.local:/usr/local
QtCreator öffnen
Tools->Options...->Devices->Add
Generic Linux Device
Ändere Hostname, authentication type key, Username und füge Private Key ( ~/.ssh/id_rsa ) hinzu
Tools->Options...->Build&Run->Debuggers->Add
Ändere name und Verzeichnis ( /opt/qt5pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gdb )
Der Debugger aus dem Toolchain funktioniert mit qtcreator nicht.
Man muss gdb-multiarch auf dem Hostsystem installieren (Danke an GrisuMS für den Hinweis) und dessen Pfad (meist /usr/bin/gdb-multiarch ) verwenden.
Tools->Options...->Compilers->Add->GCC->C
Ändere name und Verzeichnis ( /opt/qt5pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc )
ABI von <Benutzerdefiniert> auf arm-linux-generic-elf-32bit ändern
Tools->Options...->Compilers->Add->GCC->C++
Ändere name und Verzeichnis ( /opt/qt5pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++ )
ABI von <Benutzerdefiniert> auf arm-linux-generic-elf-32bit ändern
Tools->Options...->Qt Versions->Add
Wähle /opt/qt5pi/sysroot/usr/local/qt5pi/bin/qmake
Tools->Options...->Kits->Add
Ändere Name
Geräte Typ: Generic Linux Device
Gerät: Wähle zuvor erstelltes Raspberry Pi Gerät
Sysroot: Wähle /opt/qt5pi/sysroot
C and C++: Wähle zuvor erstellten Raspberry Pi Kompiler
Debugger: Wähle zuvor erstellten Raspberry Pi Debugger
Qt version: Wähle zuvor erstellte Raspberry Pi Qt Version
Fertig

Nachdem man ein Projekt angelegt hat muss man noch folgendes an das Ende der .pro Datei schreiben:
Code: Select all
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /home/pi/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
Drückt man den grünen Play-Button, wird kompiliert, die Binary per sftp auf die Raspberry Pi hochgeladen und ausgeführt
Der Debug-Button sollte ebenfalls funktionieren.
*edit
Bitte hängt bei Problemen die Logdateien an, welche euch zur Verfügung stehen. Nutzt zum hochladen der Dateien zum Beispiel pastebin.com
*edit
Einige kleine Updates gemacht. Qt 5.11.1 muss noch warten, da gibts noch viele Bugs.
Außerdem hab ich ein Bash Script angehängt womit man die Schritte ab "Toolchain herunterladen" automatisch ausführen kann. Ich werd dazu nicht viel erklären... wer wissen will wie es funktioniert muss sich mit Bash Scripting auseinandersetzen

*edit
Leichte Korrekturen. Wer übrigens eine Standaloneanwendung programmieren will und auf 5.11.1 besteht, kann buildroot 2018.08.2 verwenden. Ich will dazu noch nichts sagen... teste selbst noch, aber ich werde hier eine Ergänzung einfügen sobald ich sicher bin, dass der build gut funktioniert.
Außerdem gibt es noch ein paar Stolpersteine. Ist also nix für Anfänger