Get the latest raspbian image here
Uncomment the deb-src line in /etc/apt/sources.list and update raspbian
sudo nano /etc/apt/sources.listsudo apt-get update
sudo apt-get upgrade
sudo shutdown -r nowsudo rpi-update
sudo shutdown -r nowchange the GPU memory to 256MB and boot with "wait for network on boot"
sudo raspi-config(Optional) Install and configure touch-screen display.
sudo apt-get build-dep qt4-x11
sudo apt-get build-dep libqt5gui5
sudo apt-get install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0
sudo apt-get install cmakesudo apt-get install bluez libbluetooth-devsudo apt-get install libasound2-dev pulseaudio libpulse-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad libgstreamer-plugins-bad1.0-dev gstreamer1.0-pulseaudio gstreamer1.0-tools gstreamer1.0-alsasudo apt-get install libcups2-devsudo apt-get install libatspi-devDownload mysql c connector source from here (Source code, Generic Linux (Arsitecture Independent))
i will install it on /opt/local/mysql-rpi-src
tar zxvf mysql-connector-c-6.1.11-src.tar.gz
cd mysql-connector-c-6.1.11-src
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/opt/local/mysql-rpi-src
make
sudo make installAlso add missing symbolic links
sudo ln -s /opt/local/mysql-rpi-src/lib/libmysqlclient.so.18 /usr/lib/arm-linux-gnueabihf/sudo mkdir /usr/local/qt5pi
sudo chown pi:pi /usr/local/qt5piI use Ubuntu x64 and Qt 5.10.1
sudo apt-get update
sudo apt-get -y upgradesudo apt-get install git bison python gperfssh-keygen -t rsa
ssh-copy-id pi@<raspi ip>change
<raspi ip>address of Raspberry Pi
sudo mkdir /opt/raspi
sudo chmod a+w /opt/raspi
cd /opt/raspigit clone https://github.com/raspberrypi/toolsAdd toolchain binary directory to PATH. Open .bashrc
nano ~/.bashrcand add line at end of file
export PATH=$PATH:/opt/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/binupdate bashrc
source ~/.bashrcUsing rsync we can properly keep things synchronized in the future as well
mkdir -p sysroot/{opt,usr}
rsync -avz pi@<raspi ip>:/lib sysroot
rsync -avz pi@<raspi ip>:/usr/include sysroot/usr
rsync -avz pi@<raspi ip>:/usr/lib sysroot/usr
rsync -avz pi@<raspi ip>:/opt/vc sysroot/opt
rsync -avz pi@<raspi ip>:/opt/local sysroot/opt/Also copy mysql-rpi-src to host /opt
This use for ./configure flag: MYSQL_PREFIX=/opt/local/mysql-rpi-src
rsync -avz pi@<raspi ip>:/opt/local /opt/change
<raspi ip>address of Raspberry Pi
Create correct symlinks to "missing" libraries
mv sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0 sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0_backup
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/libEGL.so sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0
ln -s sysroot/opt/vc/lib/libGLESv2.so sysroot/usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0Please make sure to also add missing symbolic links
ln -s sysroot/opt/vc/lib/libEGL.so sysroot/opt/vc/lib/libEGL.so.1
ln -s sysroot/opt/vc/lib/libGLESv2.so sysroot/opt/vc/lib/libGLESv2.so.2Use provided script, because the old fixQualifiedLibraryPaths is not working properly
wget https://raw.githubusercontent.com/riscv/riscv-poky/priv-1.10/scripts/sysroot-relativelinks.py
chmod +x sysroot-relativelinks.py
./sysroot-relativelinks.py sysrootwget https://download.qt.io/official_releases/qt/5.10/5.10.1/single/qt-everywhere-src-5.10.1.tar.xzand extract it
tar Jxvf qt-everywhere-src-5.10.1.tar.xzCreate hf configuration
cp -rv 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.confCreate build dir
mkdir qt5build
cd qt5buildConfigure Qt
../qt-everywhere-src-5.10.1/configure -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /opt/raspi/sysroot -prefix /usr/local/qt5pi -opensource -confirm-license -plugin-sql-mysql MYSQL_PREFIX=/opt/local/mysql-rpi-src -recheck-all -skip qtwebengine -skip qtscript -make libs -no-use-gold-linker -vIf you failed, you can delete qt5build directory and try again
cd ..
rm -rvf qt5buildgit clone git://code.qt.io/qt/qtbase.git -b <qt-version>
cd qtbasechange
<qt-version>with a proper Qt version I use 5.10; Note that version 5.10.1 is a tag not a branch, so you may want to create a local branch with it
Configure Qt
./configure -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /opt/raspi/sysroot -prefix /usr/local/qt5pi -opensource -confirm-license -plugin-sql-mysql MYSQL_PREFIX=/opt/local/mysql-rpi-src -recheck-all -skip qtwebengine -skip qtscript -make libs -no-use-gold-linker -vIf you failed, you can clear everything with:
git clean -dfxSadly QtWebengine dont compile on Raspberry Pi 1 (maybe also Pi 2), so we have to skip it. Also skip QtScript, its deprecated.
For every version of Raspberry Pi, you have to change -device
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++
You probably also want to add -jn option to make command, where n is a number of cores you like to use for the complication
make
make installWe simply sync everything from /opt/raspi/sysroot/usr/local/qt5pi to the prefix we configured above
cd /opt/raspi
rsync -avz sysroot/usr/local/qt5pi pi@<raspi ip>:/usr/localchange
<raspi ip>address of Raspberry Pi
Once Qt is on the device, Qt Creator can be set up to build, deploy, run and debug Qt apps directly on the device with one click.
Go to Options -> Devices
Add
Change the name
Generic Linux Device
Enter IP address
authentication type key
user & add private key ( ~/.ssh/id_rsa )
Finish
Go to Options -> Build&Run -> Debuggers
Add
/opt/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gdb
Go to Options -> Build & Run -> Compilers
Add
GCC -> C++
Compiler path: /opt/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++
ABI: arm - linux - generic - elf - 32bit
Add
GCC -> C
Compiler path: /opt/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc
ABI: arm - linux - generic - elf - 32bit
Go to Options -> Build & Run -> Qt Versions
Add
/opt/raspi/sysroot/usr/local/qt5pi/bin/qmake
Go to Options -> Build & Run -> Kits
Add
Change the name & icon
Device type: Generic Linux Device
Device: the one we just created
Sysroot: ~/raspi/sysroot
Compiler: the one we just created
Debugger: the one we just created
Qt version: the one we saw under Qt Versions
Qt mkspec: leave empty
Done. At this point you should be able to start a new project with the new kit, build and deploy it, etc.
If you press compile Button inside QtCreator, source will just compile. If you press the green Play button, source will compile, upload binary with sftp and executed on your Raspberry Pi. Debug button should also work