Setup Raspberry Pi
Setup Raspberry Pi
Setup Host PC (Ubuntu)
Setup Host PC (Ubuntu)
Offıcial Raspian image is installed
Offıcial Raspian image is installed
SSH is enabled
SSH is enabled
Network (Wired or Wireless) Is Set
Network (Wired or Wireless) Is Set
Prerequisities
Prerequisities
GIT is installed
GIT is installed
Python 2.7 is installed
Python 2.7 is installed
SSH connection to Raspberry is set
SSH connection to Raspberry is set
Prerequisities
Prerequisities
Installing Development Libraries
Installing Development Libraries
Preparing Target Folder
/usr/local/qt5
Preparing Target Folder…
Viewer does not support full SVG 1.1

UNDER CONSTRUCTION

 

I am using Ubuntu 18.04; to have a portable and fresh setup I am using a virtual machine. Initially I set my disk space as 100GB for this virtual machine. Believe me you will need it as you start to build your programs. A small confession here; old habit from Amiga years; I was using FileMaster and Directory Opus. On Windows, I have started to use Windows Commander which became Total Commander made by Christian Ghisler. It is an excellent tool and I never use mouse for file operations. Windows Explorer, WinZIP, WinRAR and many other things too. I even use Androıd version on my phone. Anyway, old habit, sometimes I prefer to use a file manager; Double Commander is the closest software that I could find on Linux so far, it has the same layout and keyboard shortcuts with Total Commander.

sudo apt-get install doublecmd-qt

On my new machine, as always I need git first.

sudo apt-get update

sudo apt-get install git

And for starters, we will need python too:

sudo apt-get install python2.7

I am using my home directory; and I need to get Raspberry Pi build tools first. This is the toolchain to compile programs for Raspberry Pi.

Toolchain takes around 600MB disk space.

mkdir ~/raspi

cd raspi/

git clone https://github.com/raspberrypi/tools

In case you want to visit here is a quick link to GitHub page: https://github.com/raspberrypi/tools

At this point you will need your Raspberry Pi up and running already. If you haven’t changed it yet, default user name of Raspian is pi and the default password is raspberry.

And you will need to know the IP address of your Raspberry Pi, and of course your PC should be in the same network with it. On my Raspian installation, a popup window shows the IP address acquired after boot is complete. Or you can simply run this command to see your Raspberry Pi’s IP address:

ifconfig

For the sake of simplicity I generally set it to a static IP address. Mine was 192.168.1.62 when I was creating this post.

Now we will need to setup sysroot. What is this and why? Well, we are going to compile programs for Raspberry Pi, we will need header files, libraries for this. So we will need the same headers, libraries on Raspberry Pi image on our host (desktop) machine.

mkdir sysroot sysroot/usr sysroot/opt

At this point you should have a directory structure like this:

rsync -avz pi@192.168.1.62:/lib sysroot (dont forget to change the IP address to your Raspberry Pi’s address, similarly if you have changed your user name on your Raspberry Pi, you will need to replace pi name with your user name. Again, by default it is raspberry)

rsync command allows synchronization of two locations, locally or remotely. Command format is:

rsync options source destination

We will synchronize the Raspberry Pi’s lib folder with our sysroot folder on host machine. Of course this command will need password for your Raspberry Pi user.

After synchronization; your sysroot folder under raspi folder should look like this. Synchronization will take some time depending on your LAN speed. Just for your information; lib folder was around 615MB for my Raspberry Pi 3+ Rev B with stock Raspian image.

Among lib folder there are three folders that we need to synchronize:

rsync -avz pi@192.168.1.62:/usr/include sysroot/usr

rsync -avz pi@192.168.1.62:/usr/lib sysroot/usr (this is a coffee break long operation. USR folder is round 1.8GB in total)

rsync -avz pi@192.168.1.62:/opt/vc sysroot/opt (this is not that big, only 40MB)

Please note that if you change something at your target (Raspberry Pi), for instance if you add a new library, you will need to re-rsync.

Now we have the same directory structure at both host Linux PC (or virtual machine) and Rsapberry Pi. This is not a network share, we actually have two identical directory structures at two locations. Paths to these locations needs to be compatible. 

wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py

chmod +x sysroot-relativelinks.py

./sysroot-relativelinks.py sysroot

It is time to download Qt for our host (Desktop) PC:

wget http://download.qt.io/official_releases/qt/5.12/5.12.5/single/ qt-everywhere-src-5.12.5.tar.xz (This file is around 480MB)

And we will extract it:

tar xvf qt-everywhere-src-5.12.5.tar.xz

And let’s go in:

cd qt-everywhere-src-5.12.5

Now we will need to fix something and we will need a text editor. I am not going to use vim but if you will:

vim ./qtbase/mkspecs/devices/linux-rasp-pi-g++/qmake.conf

Since I am using a Raspberry Pi 3, I will modify the qmake configuration under this folder. If you are using another Raspberry Pi  variant, you will need to modify the file in the corresponding folder.

IEGL needs to be replaced with -lbrcmEGLand LGLESv2 needs to be replaced with -lbrcmGLESv2) In my case they had one and two instances respectively.

Before:

After:

For a new Ubuntu installation you will need to install build-essential package Otherwise you will see a message like this:  You don’t seem to have ‘make’ or ‘gmake’ in your PATH

sudo apt-get install build-essential

 

Now we will need to configure qt before make’ing it.

./configure -release -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -skip qtwayland -skip qtlocation -skip qtscript -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -no-use-gold-linker -v -no-gbm

This is how it looked like after a successfull configure:

Configure summary: Building on: linux-g++ (x86_64, CPU features: mmx sse sse2) Building for: devices/linux-rasp-pi3-g++ (arm, CPU features: neon) Target compiler: gcc 4.8.3 Configuration: cross_compile compile_examples enable_new_dtags largefile neon precompile_header shared rpath release c++11 concurrent dbus no-pkg-config reduce_exports stl
Build options:
Mode ................................... release 
Optimize release build for size ........ no 
Building shared libraries .............. yes 
Using C standard ....................... C11 
Using C++ standard ..................... C++11 
Using ccache ........................... no 
Using gold linker ...................... no 
Using new DTAGS ........................ yes 
Using precompiled headers .............. yes 
Using LTCG ............................. no 
Target compiler supports: NEON ......... yes 
Build parts ............................ libs
Qt modules and options: Qt Concurrent .. yes 
Qt D-Bus ............................... yes 
Qt D-Bus directly linked to libdbus .... no 
Qt Gui ................................. yes 
Qt Network ............................. yes 
Qt Sql ................................. yes 
Qt Testlib ............................. yes
Qt Widgets ............................. yes 
Qt Xml ................................. yes 
Support enabled for: Using pkg-config .. no
udev ................................... yes 
Using system zlib ...................... yes 
Qt Core: DoubleConversion .............. yes 
Using system DoubleConversion .......... no 
GLib ................................... no 
iconv .................................. yes
ICU .................................... no 
Tracing backend ........................ <none> 
Logging backends: journald ............. no 
syslog ................................. no 
slog2 .................................. no 
Using system PCRE2 ..................... no 
Qt Network:
getifaddrs() ............... yes 
IPv6 ifname ............................ yes 
libproxy ............................... no 
Linux AF_NETLINK ....................... yes 
OpenSSL ................................ no 
Qt directly linked to OpenSSL .......... no 
OpenSSL 1.1 ............................ no 
DTLS ................................... no 
SCTP ................................... no 
Use system proxies ..................... yes 
Qt Gui: Accessibility .................. yes 
FreeType ............................... yes 
Using system FreeType .................. no 
HarfBuzz ............................... yes 
Using system HarfBuzz .................. no 
Fontconfig ............................. no 

Image formats:
GIF .................................... yes 
ICO .................................... yes 
JPEG ................................... yes 
Using system libjpeg ................... no 
PNG .................................... yes 
Using system libpng .................... yes
EGL .................................... yes 
OpenVG ................................. no

OpenGL:
Desktop OpenGL ......................... no 
OpenGL ES 2.0 .......................... yes
OpenGL ES 3.0 .......................... no
OpenGL ES 3.1 .......................... no
OpenGL ES 3.2 .......................... no 
Vulkan ................................. yes 
Session Management ..................... yes 
Features used by QPA backends: evdev ... yes 
libinput ............................... no 
INTEGRITY HID .......................... no 
mtdev .................................. no 
tslib .................................. yes 
xkbcommon .............................. no 

X11 specific:
XLib ................................... yes 
XCB Xlib ............................... no 
EGL on X11 ............................. no

QPA backends:
DirectFB ............................... no
EGLFS .................................. yes

EGLFS details:
EGLFS OpenWFD .......................... no
EGLFS i.Mx6 ............................ no
EGLFS i.Mx6 Wayland .................... no
EGLFS RCAR ............................. no
EGLFS EGLDevice ........................ no
EGLFS GBM .............................. no
EGLFS VSP2 ............................. no
EGLFS Mali ............................. no
EGLFS Raspberry Pi ..................... yes
EGLFS X11 .............................. no
LinuxFB ................................ yes
VNC .................................... yes
Mir client ............................. no 

Qt Sql
SQL item models ........................ yes 
Qt Widgets: GTK+ ....................... no 
Styles ................................. Fusion Windows 

Qt PrintSupport:
CUPS ................................... no 
Qt Sql Drivers: DB2 (IBM) .............. no 
InterBase .............................. no 
MySql .................................. no 
OCI (Oracle) ........................... no 
ODBC ................................... no 
PostgreSQL ............................. no 
SQLite2 ................................ no 
SQLite ................................. yes
Using system provided SQLite ........... no
TDS (Sybase) ........................... no 
Qt Testlib: 
Tester for item models ................. yes 

Qt SerialBus:
Socket CAN ............................. yes 
Socket CAN FD .......................... yes 

Further Image Formats:
JasPer ................................. no 
MNG .................................... no 
TIFF ................................... yes 
Using system libtiff ................... no 
WEBP ................................... yes 
Using system libwebp ................... no 

Qt QML: 
QML network support .................... yes 
QML debugging and profiling support .... yes
QML sequence object .................... yes
QML list model ......................... yes
QML XML http request ................... yes
QML Locale ............................. yes
QML delegate model ..................... yes

Qt Quick: 
Direct3D 12 ............................ no 
AnimatedImage item ..................... yes 
Canvas item ............................ yes 
Support for Qt Quick Designer .......... yes 
Flipable item .......................... yes 
GridView item .......................... yes 
ListView item .......................... yes 
TableView item ......................... yes 
Path support ........................... yes 
PathView item .......................... yes 
Positioner items ....................... yes 
Repeater item .......................... yes 
ShaderEffect item ...................... yes 
Sprite item ............................ yes 

Qt Scxml: 
ECMAScript data model for QtScxml ...... yes 

Qt Gamepad:
SDL2 ................................... no 

Qt 3D:
Assimp ................................. yes 
System Assimp .......................... no 
Output Qt3D Job traces ................. no 
Output Qt3D GL traces .................. no 
Use SSE2 instructions .................. no 
Use AVX2 instructions .................. no 
Aspects: Render aspect ................. yes 
Input aspect ........................... yes 
Logic aspect ........................... yes 
Animation aspect ....................... yes 
Extras aspect .......................... yes 

Qt 3D Renderers: 
OpenGL Renderer ........................ yes 

Qt 3D GeometryLoaders: 
Autodesk FBX ........................... no 

Qt Bluetooth:
BlueZ .................................. no 
BlueZ Low Energy ....................... no
Linux Crypto API ....................... no
WinRT Bluetooth API (desktop & UWP) .... no

Qt Sensors:
sensorfw ............................... no
Qt Quick Controls 2:
Styles ................................. Default

Fusion Imagine Material Universal Qt Quick Templates 2:
Hover support .......................... yes 
Multi-touch support .................... yes 

QtXmlPatterns:
XML schema support ..................... yes 

Qt Multimedia:
ALSA ................................... no
GStreamer 1.0 .......................... no
GStreamer 0.10 ......................... no
Video for Linux ........................ yes
OpenAL ................................. no
PulseAudio ............................. no
Resource Policy (libresourceqt5) ....... no
Windows Audio Services ................. no
DirectShow ............................. no
Windows Media Foundation ............... no

Qt Tools:
QDoc ................................... no

Qt WebEngine:
Embedded build ......................... yes 
Full debug information ................. no 
Pepper Plugins ......................... no 
Printing and PDF ....................... no
Proprietary Codecs ..................... no
Spellchecker ........................... yes
Native Spellchecker .................... no 
WebRTC ................................. no 
Use System Ninja ....................... no 
Geolocation ............................ no 
WebChannel support ..................... yes 
Use v8 snapshot ........................ yes 
Kerberos Authentication ................ no 
Support qpa-xcb ........................ no 
Building v8 snapshot supported ......... no 
Use ALSA ............................... no 
Use PulseAudio ......................... no 

Optional system libraries used: 
re2 .................................. no 
icu .................................. no 
libwebp, libwebpmux and libwebpdemux . no 
opus ................................. no 
ffmpeg ............................... no 
libvpx ............................... no 
snappy ............................... no 
glib ................................. no
zlib ................................. no 
minizip .............................. no 
libevent ............................. no 
jsoncpp .............................. no 
protobuf ............................. no 
libxml2 and libxslt .................. no 
lcms2 ................................ no 
png .................................. no 
JPEG ................................. no 
harfbuzz ............................. no 
freetype ............................. no 

Required system libraries: 
fontconfig ........................... no 
dbus ................................. no 
nss .................................. no
khr .................................. yes 
glibc ................................ yes 

Required system libraries for qpa-xcb:
x11 .................................. no
 
libdrm ............................... no 
xcomposite ........................... no 
xcursor .............................. no 
xi ................................... no 
xtst ................................. no 
Note: Also available for Linux: linux-clang linux-icc WARNING: QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation. Either ensure that llvm-config is in your PATH environment variable, or set LLVM_INSTALL_DIR to the location of your llvm installation. On Linux systems, you may be able to install libclang by installing the libclang-dev or libclang-devel package, depending on your distribution. On macOS, you can use Homebrew's llvm package. On Windows, you must set LLVM_INSTALL_DIR to the installation path. WARNING: Python version 2 (2.7.5 or later) is required to build QtWebEngine. WARNING: gperf is required to build QtWebEngine. WARNING: bison is required to build QtWebEngine. WARNING: flex is required to build QtWebEngine. WARNING: host pkg-config not found Qt is now configured for building. Just run 'make'. Once everything is built, you must run 'make install'. Qt will be installed into '/home/gokhan/raspi/qt5pi'. Prior to reconfiguration, make sure you remove any leftovers from the previous build. 

Let’s stop here for a second. You could need a different set of parameters for your application. For configuration options qtbase/config_help.txt file is worth reading.

If you need QtWebEngine too, there are some prerequisites. Assuming you already have python 2.7 installed, at Raspberry Pi:

sudo apt-get install libclang-dev
sudo apt-get install gperf
sudo apt-get install bison

Of course you will need to re-do rsync operations mentioned above after installing these packages.

Core options:

  -doubleconversion .... Select used double conversion library [system/qt/no]
                         No implies use of sscanf_l and snprintf_l (imprecise).
  -glib ................ Enable Glib support [no; auto on Unix]
  -eventfd ............. Enable eventfd support
  -inotify ............. Enable inotify support
  -iconv ............... Enable iconv(3) support [posix/sun/gnu/no] (Unix only)
  -icu ................. Enable ICU support [auto]
  -pcre ................ Select used libpcre2 [system/qt]
  -pps ................. Enable PPS support [auto] (QNX only)
  -zlib ................ Select used zlib [system/qt]

  Logging backends:
    -journald .......... Enable journald support [no] (Unix only)
    -syslog ............ Enable syslog support [no] (Unix only)
    -slog2 ............. Enable slog2 support [auto] (QNX only)
Network options:

  -ssl ................. Enable either SSL support method [auto]
  -no-openssl .......... Do not use OpenSSL [default on Apple and WinRT]
  -openssl-linked ...... Use OpenSSL and link to libssl [no]
  -openssl-runtime ..... Use OpenSSL and dynamically load libssl [auto]
  -securetransport ..... Use SecureTransport [auto] (Apple only)

  -sctp ................ Enable SCTP support [no]

  -libproxy ............ Enable use of libproxy [no]
  -system-proxies ...... Use system network proxies by default [yes]
Gui, printing, widget options:

  -cups ................ Enable CUPS support [auto] (Unix only)

  -fontconfig .......... Enable Fontconfig support [auto] (Unix only)
  -freetype ............ Select used FreeType [system/qt/no]
  -harfbuzz ............ Select used HarfBuzz-NG [system/qt/no]
                         (Not auto-detected on Apple and Windows)

  -gtk ................. Enable GTK platform theme support [auto]

  -lgmon ............... Enable lgmon support [auto] (QNX only)

  -no-opengl ........... Disable OpenGL support
  -opengl <api> ........ Enable OpenGL support. Supported APIs:
                         es2 (default on Windows), desktop (default on Unix),
                         dynamic (Windows only)
  -opengles3 ........... Enable OpenGL ES 3.x support instead of ES 2.x [auto]
  -egl ................. Enable EGL support [auto]
  -angle ............... Use bundled ANGLE to support OpenGL ES 2.0 [auto]
                         (Windows only)
  -combined-angle-lib .. Merge LibEGL and LibGLESv2 into LibANGLE (Windows only)

  -qpa <name> .......... Select default QPA backend(s) (e.g., xcb, cocoa, windows)
                         A prioritized list separated by semi-colons.
  -xcb-xlib............. Enable Xcb-Xlib support [auto]
  Platform backends:
    -direct2d .......... Enable Direct2D support [auto] (Windows only)
    -directfb .......... Enable DirectFB support [no] (Unix only)
    -eglfs ............. Enable EGLFS support [auto; no on Android and Windows]
    -gbm ............... Enable backends for GBM [auto] (Linux only)
    -kms ............... Enable backends for KMS [auto] (Linux only)
    -linuxfb ........... Enable Linux Framebuffer support [auto] (Linux only)
    -mirclient ......... Enable Mir client support [no] (Linux only)
    -xcb ............... Enable X11 support. Select used xcb-* libraries [system/qt/no]
                         (-qt-xcb still uses system version of libxcb itself)
  Input backends:
    -libudev............ Enable udev support [auto]
    -evdev ............. Enable evdev support [auto]
    -imf ............... Enable IMF support [auto] (QNX only)
    -libinput .......... Enable libinput support [auto]
    -mtdev ............. Enable mtdev support [auto]
    -tslib ............. Enable tslib support [auto]
    -xcb-xinput ........ Enable XInput2 support [auto]
    -xkbcommon ......... Enable key mapping support [auto]
  Image formats:
    -gif ............... Enable reading support for GIF [auto]
    -ico ............... Enable support for ICO [yes]
    -libpng ............ Select used libpng [system/qt/no]
    -libjpeg ........... Select used libjpeg [system/qt/no]

If you were generous to dedicate multiple cores to your Virtual Machine; you can start make:

make -j4
make install

Even with -j4, make will take some time. May be it is time for another cup of coffee. Well, perhaps I am being optimistic here. There is time even for a long lunch-break. By the way, this build could fail. -j4 will prevent you to see where and why exactly it fails. So if the build fails, try plain old make.

If make fails with the error below, you will need to re-run this:

./sysroot-relativelinks.py sysroot
make took 4 hours for me, plenty of time to plant a couple of avocado trees, cook raspberry muffins (I am serious) and brew fresh coffee.

cd /home/gokhan/raspi

rsync -avz qt5pi pi@192.168.1.62:/usr/local

First time I did this, I installed qt and qt creator from comand line and I had difficulty to build QVirtualKeyboard. This time, I am downloading qt from here : https://www.qt.io/download

I downloaded this:

qt-unified-linux-x64-3.2.3-online.run

chmod 777 /qt-unified-linux-x64-3.2.3-online.run

./qt-unified-linux-x64-3.2.3-online.run

Then the installer should start:

These are my install options:

And finally Qt Creator is up and ready:

If you are into OpenGL stuff and if you want to be able to run it on your host machine too you will need to install libraries to your host too:

sudo apt-get install libglu1-mesa-dev

On Qt Creator, from drop-down menu, Tools – Options – Devices – Add:

Generic Linux Device and click Start Wizard

Type a name for your Raspberry and enter IP address and user name (again, the default was pi)

Now you can select one of the examples and configure for Raspberry Pi then select Debug or Release version and run it.

It will be deployed to Raspberry Pi (you may need to enter password for your Raspberry Pi user via a popup window on your host machine)

And Voila!

I will add some photos of my actual hardware setup when I tidy up my desk.

Last modified: June 27, 2020

Author