Raspberry Pi Windows
This page describes the process of setting up a development environment based on Microsoft Windows as a host system for a Raspberry Pi target running linux. The Raspberry Pi is supposed to run an embedded version of Qt without a desktop environment or window manager.
This is a work in progress.
Prepare the target
It is neccessary to setup the target first as some files from the target are required to build the embedded Qt library.
Prepare a Raspberry Pi target running Raspbian stretch as described here. https://www.raspberrypi.org/documentation/installation/installing-images/README.md Go for the lite image as we do not want a standard graphical user interface.
Enable SSH access on the Pi, for example using raspi-config => 5 Interfacing options => P2 SSH
Install some packages on the Pi
sudo apt-get install libssl1.0-dev gdbserver
Optional packages that allow bluetooth and sound drivers
sudo apt-get install libbluetooth3 libbluetooth-dev libasound2-dev
Prepare the host PC
Install necessary software
Python 2.7
https://www.python.org/downloads/release/python-2715/ Python 2.7 is required, Python 3.x will not work. No need to add python to the Path.
Strawberry Perl
http://strawberryperl.com/ No need to add python to the Path
Qt
MinGW 7.3.0 from the category Tools is required.
- Linaro Toolchain
https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabihf/
Setup sysroot
When compiling software on the host PC, the cross compiler needs files from the target. Therefore, a dump of the sysroot is necessary on the PC.
Before copying the files, run
sudo rpi-update
on the target. This adds the OpenGL Librarys to the opt-Folder.
Copy the sysroot on the windows-pc, for example C:\sysroot and copy the following directories from the Pi.
/usr/
/opt/
/lib/
Build Qt
Patch the Qt sources
https://www.qt.io/offline-installers Download the Qt sources and unpack them, for example to C:\qtbuild\qt-everywhere-src-5.12.0 The sources provides by the QtInstaller will not work!
Change the following lines in qtbase\mkspecs\devices\linux-rasp-pi3-g++\qmake.conf
VC_LIBRARY_PATH = /opt/vc/lib
VC_INCLUDE_PATH = =/opt/vc/include
to
VC_LIBRARY_PATH = $$[QT_SYSROOT]/opt/vc/lib
VC_INCLUDE_PATH = $$[QT_SYSROOT]/opt/vc/include
(Add sysroot variable and REMOVE extra =)
and
VC_LINK_LINE = -L=$${VC_LIBRARY_PATH}
to
VC_LINK_LINE = -L$${VC_LIBRARY_PATH}
(Remove =)
QMAKE_LIBS_EGL = $${VC_LINK_LINE} -lEGL -lGLESv2
to
QMAKE_LIBS_EGL = $${VC_LINK_LINE} -lbrcmEGL -lbrcmGLESv2
Start a Qt Command line:
Add python and perl to the environment
set PATH=C:\Python27;C:\Strawberry\perl\bin;C:\qtbuild\gcc-linaro-7.3.1-2018.05-i686-mingw32_arm-linux-gnueabihf\gcc-linaro-7.3.1-2018.05-i686-mingw32_arm-linux-gnueabihf\bin;%PATH%
..\qt-everywhere-src-5.12.0\configure -platform win32-g++ -release -opengl es2 -device linux-rasp-pi3-g++ -sysroot C:/raspi-sysroot -prefix /usr/local/qt5 -opensource -confirm-license -device-option CROSS_COMPILE=arm-linux-gnueabihf- -skip qtlocation -skip qtscript -nomake examples -hostprefix C:/raspi-sysroot/usr/local/qt5
Fix prefix
Somehow the configure puts a wrong prefix in qtbase\bin\qt.conf:
Build Qt
mingw32-make -j 2
Install Qt into the sysroot
mingw32-make install
Install Qt on the Pi
Setup QtCreator
References
- Tutorial working up to Qt 5.5 https://visualgdb.com/tutorials/raspberry/qt/embedded/
- Tutorial working up to Qt 5.8 https://forum.qt.io/topic/68381/cross-compile-qt-windows-to-raspberry-3/26