If You want to build Qt5 development environmet for raspberry pi then you are in the right place. In this short tutorial you can build your Qt5 for raspberry pi. I used ubuntu-18.04-desktop-amd64 and rasp image is 2018-06-27-raspbian-stretch. For old images something can be different. If you have any trouble, then let me know I can help you.

Qt is a framework. What is framework ? Framework is a platform which includes several tools that makes your life easier. For example GUI libraries of Qt. They are best for me. One much more thing: you develop applications with C++ in Qt. ( Qt is cute not quti )

You can develop Qt applications for different hardware architectures. For raspberry pi we create a virtual machine ( host ) and we compile our projecst crossly. I just try to say we must make a cross compilation. As it is obvious our host hardware is (most probably) intel but the raspberry pi is ARM. They are totally different. Like white and black or Brad and Angelina. So to make understandable (?) what we do in intel, we cross compile our code then it will be ok for Rasp. To do that we need some toolchains that we will install in our virtual machine.

First thing first, lets create a virtual machine with virtual box. You can download virtual box from here https://www.virtualbox.org/wiki/Downloads

Then follow instruction in the video. Give about 30 GB space , it is enough. Then open it.
Before go raspberry pi, be sure that , you supply the raspberry pi 5V 2.1A power source or much current. If you suppy it from your computer or you phone charger , then you will waste your hours in the next. If rasp is connected to the HDMI and you see the yellow lightning figure for a long time then you will have a power problem. If you have a problems with power do not go further ! Power be with you ! )

Now go to raspberry pi. Make it ssh available, ( create a directory which name is ssh in the boot directory with cmd.exe) log in with ssh. With putty ( you can use different serial terminal/emulator ) log in, User name is pi, passwd raspberry. Now change the root passwd and enable to login as a root.

sudo nano /etc/ssh/sshd_config

find the line PermitRootLogin and make it comment out.

then say yes

PermitRootLogin yes

to out ctrl -x and push the y

then give root password.

sudo passwd root
(mine is 1234)
sudo reboot

login as a root. User name is “root” and paswwd is “what you give”


nano /etc/apt/sources.list
uncomment the last line. apt-get update
apt-get dist-upgrade
-be sure rpi update work, try rpi-update again
*** Your firmware is already up to date – OKAY
sudo apt-get build-dep qt5-qmake
sudo apt-get build-dep libqt5webengine-data
sudo apt-get install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0
mkdir /usr/local/qt5pi
chown -R root:root /usr/local/qt5pi

That is ok for Raspberr pi. Do not power off it. We have a long night…

In ubuntu :
We create the vm open it, ( for network connect it via ethernet cable. I did it like that I did not have to make any additional configuration, I did not use Wifi. Create a good network with cables between your raspberry pi and computer. )

sudo passwd root


apt-get update

apt-get -y upgrade

apt-get install gcc git bison python gperf pkg-config

sudo mkdir /opt/qt5pi

sudo chown 1000:1000 /opt/qt5pi

cd /opt/qt5pi

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

nano ~/.bashrc – it keep to long

export PATH=$PATH:/opt/qt5pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin


wget http://download.qt.io/official_releases/qt/5.10/5.10.1/single/qt-everywhere-src-5.10.1.tar.xz

tar xf qt-everywhere-src-5.10.1.tar.xz
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

mkdir sysroot sysroot/usr sysroot/opt

rsync -avz root@ sysroot

rsync -avz root@ sysroot/usr

rsync -avz root@ sysroot/usr

rsync -avz root@ sysroot/opt

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

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

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.2

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

chmod +x sysroot-relativelinks.py

./sysroot-relativelinks.py sysroot

check syncronized file again

rsync -avz root@ sysroot

rsync -avz root@ sysroot/usr

rsync -avz root@ sysroot/usr

rsync -avz root@ sysroot/opt

./sysroot-relativelinks.py sysroot

mkdir qt5build

cd qt5build

../qt-everywhere-src-5.10.1/configure -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /opt/qt5pi/sysroot -prefix /usr/local/qt5pi -opensource -confirm-license -skip qtscript -nomake examples -make libs -pkg-config -no-use-gold-linker -v

=> for raspberry pi 0 => -device linux-rasp-pi-g++

=> for raspberry pi 2 => -device linux-rasp-pi2-g++

=> for raspberry pi 3 => -device linux-rasp-pi3-g++

=> for raspberry pi 3 + vc4 driver => -device linux-rasp-pi3-vc4-g++

make -j4

make install

cd /opt/qt5pi

rsync -avz sysroot/usr/local/qt5pi root@

install qt-creator

apt-get install qtcreator

Lets create simple Hello world console application. With qt-creator choose new console application.

#include <QCoreApplication>
#include <QDebug>

int main(int argc, char *argv[])
    QCoreApplication a(argc, argv);

    qDebug()<<"Hello World"<<endl;

    return a.exec();
QT -= gui

CONFIG += c++11 console
CONFIG -= app_bundle

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += main.cpp

Go to path where your pro file stays.
Call the qmake with command
then hit enter after that you will see the Makefile . Check with the ls command
to create a executable binary just
As it seen with file untitled, it is for ARM not intel.
Send it to the raspberr pi with
scp untitled root@
Back to raspberry pi. Go to home. Then ./untitled.
Hello World.


Leave a Comment

Your email address will not be published. Required fields are marked *