0% found this document useful (0 votes)
151 views13 pages

Cross Compile QT5 Sources

The document discusses cross-compiling QT5 using a custom built cross-compiler for the Raspberry Pi 3. It describes creating a new mkspecs directory for the compiler, modifying configuration files to use the new compiler, and running configure to build QT5 while specifying the cross-compiler, sysroot and target device as the Raspberry Pi 3. The result of running configure is shown, indicating many libraries are not included in the build.

Uploaded by

ap8389546
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
151 views13 pages

Cross Compile QT5 Sources

The document discusses cross-compiling QT5 using a custom built cross-compiler for the Raspberry Pi 3. It describes creating a new mkspecs directory for the compiler, modifying configuration files to use the new compiler, and running configure to build QT5 while specifying the cross-compiler, sysroot and target device as the Raspberry Pi 3. The result of running configure is shown, indicating many libraries are not included in the build.

Uploaded by

ap8389546
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Cross compile QT5 sources

Using the buildroot external created cross compiler:

/home/first/buildroot/blrpi3_32/buildroot-2017.05/output/host/usr/bin

http://doc.qt.io/qt-5/configure-options.html

First we need to make sure our cross compiler is in the path:


lets create an ACTIVATE.sh script and source it

export PATH=/home/first/buildroot/blrpi3_32/buildroot-2017.05/output/host/usr/bin:$PATH
source ACTIVATE.sh

Pointless to say that the compiler need to be fit to the architecture


means , 32 ot 64 bit , glibc , uclibc , endianess and so on

make sure you can call it any where:

aarch64-linux-gnu-g++

aarch64-linux-gnu-g++: fatal error: no input files


compilation terminated.

A list of platform can be found in: qtbase/mkspecs

Note that we dont have our compiler that we create using cross too ng

lets create a mkspecs there for our compiler:

Src/qtbase/mkspecs$ cp -r linux-arm-gnueabi-g++ aarch64-linux-gnu-g++

This is the current qmake.conf that we copied from:

#
# qmake configuration for building with arm-linux-gnueabi-g++
#
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib

include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)

# modifications to g++.conf
QMAKE_CC = arm-linux-gnueabi-gcc
QMAKE_CXX = arm-linux-gnueabi-g++
QMAKE_LINK = arm-linux-gnueabi-g++
QMAKE_LINK_SHLIB = arm-linux-gnueabi-g++

# modifications to linux.conf
QMAKE_AR = arm-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = arm-linux-gnueabi-objcopy
QMAKE_NM = arm-linux-gnueabi-nm -P
QMAKE_STRIP = arm-linux-gnueabi-strip
load(qt_config)

We need to change the compiler prefix to aarch64-linux-gnu-g++

#
# qmake configuration for building with aarch64-linux-gnu-g++
#

MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib

include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)

# modifications to g++.conf
QMAKE_CC = aarch64-linux-gnu-gcc
QMAKE_CXX = aarch64-linux-gnu-g++
QMAKE_LINK = aarch64-linux-gnu-g++
QMAKE_LINK_SHLIB = aarch64-linux-gnu-g++

# modifications to linux.conf
QMAKE_AR = aarch64-linux-gnu-ar cqs
QMAKE_OBJCOPY = aarch64-linux-gnu-objcopy
QMAKE_NM = aarch64-linux-gnu-nm -P
QMAKE_STRIP = aarch64-linux-gnu-strip
load(qt_config)

./configure -platform
-device - a specific device or chipsets. The list of devices that configure is compatible
with are found in qtbase/mkspecs/devices. For more information, visit
the Devices Wiki page.

We can create a new device and put all the options there

lets use raspberry pi 3

./configure -device linux-rasp-pi3-g++

-device-option - sets additional qmake variables. For example, -device-option


CROSS_COMPILE=<path-to-toolchain> provides the environment
variable, CROSS_COMPILE, as needed by certain devices.

-sysroot specify the root file system ( can be take from buildroot)
-sysroot /home/first/buildroot/blrpi3_32/buildroot-2017.05/output/host/usr/aarch64-buildroot-
linux-gnu/sysroot

-opensource -confirm-license

For configure , xplatform cannot be with -device


Use device-option to sepcify the compiler
./configure -device linux-rasp-pi3-g++
-device-option CROSS_COMPILE=aarch64-linux-gnu-
-sysroot /home/first/buildroot/blrpi3_32/buildroot-2017.05/output/host/usr/aarch64-buildroot-
linux-gnu/sysroot

the result of the configure is not satisfied, many libraries are not included.

Build options:
Mode ................................... release
Optimize release build for size ........ no
Building shared libraries .............. yes
Using C++ standard ..................... C++1z
Using gold linker ...................... no
Using new DTAGS ........................ yes
Using precompiled headers .............. yes
Using LTCG ............................. no
Target compiler supports:
NEON ................................. yes
Build parts ............................ libs examples
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
QML debugging .......................... yes
udev ................................... no
Using system zlib ...................... no
Qt Core:
DoubleConversion ....................... yes
Using system DoubleConversion ........ no
GLib ................................... no
iconv .................................. yes
ICU .................................... no
Logging backends:
journald ............................. no
syslog ............................... no
slog2 ................................ no
Using system PCRE2 ..................... no
Qt Network:
getaddrinfo() .......................... yes
getifaddrs() ........................... yes
IPv6 ifname ............................ yes
libproxy ............................... no
OpenSSL ................................ no
Qt directly linked to OpenSSL ........ no
SCTP ................................... no
Use system proxies ..................... yes
Qt Sql:
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 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 ................ no
EGL .................................... no
OpenVG ................................. no
OpenGL:
Desktop OpenGL ....................... no
OpenGL ES 2.0 ........................ no
OpenGL ES 3.0 ........................ no
OpenGL ES 3.1 ........................ no
Session Management ..................... yes
Features used by QPA backends:
evdev .................................. yes
libinput ............................... no
mtdev .................................. no
tslib .................................. no
xkbcommon-evdev ........................ no
QPA backends:
DirectFB ............................... no
EGLFS .................................. no
LinuxFB ................................ yes
VNC .................................... yes
Mir client ............................. no
Qt Widgets:
GTK+ ................................... no
Styles ................................. Fusion Windows
Qt PrintSupport:
CUPS ................................... no
Qt SerialBus:
Socket CAN ............................. yes
Socket CAN FD .......................... yes
QtXmlPatterns:
XML schema support ..................... yes
Qt QML:
QML interpreter ........................ yes
QML network support .................... yes
Qt Quick:
Direct3D 12 ............................ no
AnimatedImage item ..................... yes
Canvas item ............................ yes
Support for Quick Designer ............. yes
Flipable item .......................... yes
GridView item .......................... yes
ListView item .......................... yes
Path support ........................... yes
PathView item .......................... yes
Positioner items ....................... yes
ShaderEffect item ...................... yes
Sprite item ............................ yes
Qt Gamepad:
SDL2 ................................... no
Qt 3D:
Assimp ................................. yes
System Assimp .......................... no
Output Qt3D Job traces ................. no
Output Qt3D GL traces .................. no
Qt 3D GeometryLoaders:
Autodesk FBX ........................... no
Qt Wayland Client ........................ no
Qt Wayland Compositor .................... no
Qt Bluetooth:
BlueZ .................................. no
BlueZ Low Energy ....................... no
Linux Crypto API ....................... no
Qt Sensors:
sensorfw ............................... no
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 Quick Controls 2:
Styles ................................. Default Material Universal
Qt Quick Templates 2:
Hover support .......................... yes
Qt Location:
Gypsy GPS Daemon ....................... no
WinRT Geolocation API .................. no
Qt WebEngine:
Embedded build ......................... yes
Pepper Plugins ......................... no
Printing and PDF ....................... no
Proprietary Codecs ..................... no
Spellchecker ........................... yes
WebRTC ................................. no
Using system ninja ..................... no
ALSA ................................... no
PulseAudio ............................. no
System libraries:
ICU .................................. no
libwebp and libwebpdemux ............. no
Opus ................................. no
ffmpeg ............................... no

becaouse we dont have open gl in out buildroot sysroot


We cannot compile to create a makefile , so we get an error:

Note: Also available for Linux: linux-clang linux-icc

Note: No wayland-egl support detected. Cross-toolkit compatibility disabled.

ERROR: The OpenGL functionality tests failed!


You might need to modify the include and library search paths by editing
QMAKE_INCDIR_OPENGL[_ES2],
QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your
platform.

lets add for now the -no-opengl to the compile script

lets add -prefix to /usr/local/qt5.9

Qt is now configured for building. Just run 'make'.


Once everything is built, you must run 'make install'.
Qt will be installed into '/home/first/buildroot/blrpi3_32/buildroot-2017.05/output/host/usr/aarch64-
buildroot-linux-gnu/sysroot/usr/local/qt5.9'.

It will be installed in the buildroot usr/local/qt5.9

now we can run make for ever

Compile an example:
Go to the examples directory:

for example:
/home/first/Qt/Examples/Qt-5.9/embedded/flickable
/home/first/Qt/Examples/Qt-5.9/widgets/dialogs/tabdialog

create a compile bash script:

/home/elia/Downloads/buildroot_for_raspi3/output/host/usr/bin/qmake $1 -spec aarch64-linux-


gnu-g++ CONFIG

we have two options


1. Use buildroot QT qmake ( after we added QT 5 to buildroot)
2. Use the QT5 compilation that we make from the sources by our self.

note , if dont compile buildroot with QT we will not have qmake in the bin folder
( Or cross compile it from source)

if QT does not find the spec point it exclicty:

/home/first/buildroot/blrpi3_32/buildroot-2017.05/output/host/usr/bin/qmake $1 -
spec ../../../../../5.9/Src/qtbase/mkspecs/aarch64-linux-gnu-g++

./compile tabdialog.pro

compile is a script file I created

This is the compile script :

/home/first/buildroot/blrpi3_32/buildroot-2017.05/output/host/usr/bin/qmake $1 -spec
/home/first/Qt/5.9/Src/qtbase/mkspecs/aarch64-linux-gnu-g++ CONFIG+=debug
CONFIG+=qml_debug

This is the activate script:

export PATH=/home/first/buildroot/blrpi3_32/buildroot-2017.05/output/host/usr/bin:$PATH

Add QT and open GL to buildroot


open mesa 3d – an open source implementation for open gl

Add open gl Es 2.0 and default graphic platform to linuxfb.


Run the configure again:

./configure -device linux-rasp-pi3-g++


-device-option CROSS_COMPILE=aarch64-linux-gnu-
-sysroot /home/first/buildroot/blrpi3_32/buildroot-2017.05/output/host/usr/aarch64-buildroot-
linux-gnu/sysroot

When finished , we do have now qmake in:

first@eliaradfirst:~/buildroot/blrpi3_32/buildroot-2017.05$ ls output/host/usr/bin/qmake
output/host/usr/bin/qmake

* I needed to increase the block size because the file system exceed the default of 120000
Using the out cross tool ng for raspberry pi 3 cross compiler:

I compiled the croos tool ng tool-chain for raspberry pi 3


in build root I match the kernel headers to the raspberry pi 3 kernel version I.e 4.9

We select custom toolchain and pre installed

The path is a full path


to the compiler
installed by cross tool
ng without the bin
directory
The prefix is the
name of the compiler
without the - or the -
g++ for example.
You should know the toolchain compiler version from the crosstool ng menu configuration
and the kernel header are 4.9 like the raspberry pi kernel version

Btw , when I selected 4.10 I got kernel panic ( did not tried it two times to make sure it was the
problem)
but this kernel panel sync init is coming back from time to time.

This
is a

summery from the cross tool ng document I prepared:

ct-ng aarch64-rpi3-linux-gnueabi

we can see the Emit assembly for CPU – is the raspberry pi A53

Those options are also known from the compiler options:


library: glibc we do have C++

You might also like