[HowTo] Cross compile Qt5

Started by Cosik, October 27, 2014, 11:17:52 AM

Previous topic - Next topic

Cosik

1. Prepare Kernel

Information about how to compile your own kernel you could find in topic [HowTo] Enable full duplex SPI

TIP:
To get better effects of display quality you should uncomment this line in yours kernel source
https://github.com/mmplayer/linux-sunxi/blob/dev/sunxi-3.4/drivers/video/sunxi/disp/dev_fb.c#L1074

2. Build Mali Binaries
tbd.

3. Cross compile Qt5
Before you start cross-compiling Qt5 you need to prepare dependencies on your target. First run:
sudo apt-get update
sudo apt-get upgrade

Now you need to install packages:
Basic Qt dependencies:

  • libfontconfig1-dev
  • libdbus-1-dev
  • libfreetype6-dev
  • libudev-dev

Dependencies for multimedia:

  • libasound2-dev
  • libavcodec-dev
  • libavformat-dev
  • libswscale-dev
  • libgstreamer0.10-dev
  • libgstreamer-plugins-base0.10-dev
  • gstreamer-tools
  • gstreamer0.10-plugins-good
  • gstreamer0.10-plugins-bad

QtWebKit dependencies:

  • libicu-dev
  • libsqlite3-dev
  • libxslt1-dev
  • libssl-dev

All of those packages should be allready installed in release 2 of A20-Lime image.

Prepare host:
If you have 64 bit linux, necessary will installation of 32bit libraries. 
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 libstdc++6:i386 ia32-libs

Next step is mounting rootfs of our OLinuXino board. To do it we need image of our SD card or mount root fs via ssh. In this tutorial I will mount rootfs to /mnt/a20.

Image coulde be mounted:
mount -o loop,offset=17825792 /home/cosik/a20_Lime_debian_3.4.90_release_2.img /mnt/a20/

Also we can mount root fs via ssh using command
sudo sshfs -o allow_other root@192.168.1.10:/ /mnt/a20/

Remember that you need to know ip of yours board or better set static ip for it.

Next step is prepare Qt5 sources for compiling. First we need to download a cross compile. In this tutorial I use linaro 4.8-2013.09 which could be find in this link https://releases.linaro.org/13.09/components/toolchain/binaries or you could install arm-linux-gnueabihf package from repository.

No we need to fix symlinks to our Lime rootfs, so listed command shoul be executed:
git clone git://gitorious.org/cross-compile-tools/cross-compile-tools.git
cd cross-compile-tools
./fixQualifiedLibraryPaths /mnt/a20/ /home/cosik/gcc-linaro-arm-linux-gnueabihf-4.8-2013.09_linux/bin/arm-linux-gnueabihf-g++


To fix script as arguments we write location of our rootfs and second location on g++ cross compiler.

Now it's time to download Qt source which could be find here http://qt-project.org/downloads. Extract it and go to this directory in console.

Now we will add qmake config to support our Lime, so sould be executed some commands:
mkdir qtbase/mkspecs/devices/linux-a20olimex-g++/
cp qtbase/mkspecs/devices/linux-beagleboard-g++/qmake.conf qtbase/mkspecs/devices/linux-a20olimex-g++/
cp qtbase/mkspecs/devices/linux-beagleboard-g++/qplatformdefs.h qtbase/mkspecs/devices/linux-a20olimex-g++/


Now you need to open qtbase/mkspecs/devices/linux-a20olimex-g++/qmake.conf in your's favourite editor, replace content of this file with:
qplatformdefs.h

You need to remember to change rootfs if you used different than mine. Also if you have other cpu than Allwinner A20 you need to change mtune value, eg. for A10 it will be cortex-a8.

In this step we will patch EGLNativeWindowType QEglFSHooks::createNativeWindow function from qtbase/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp with:
qeglfshooks_stub.cpp

Now it's time to configure our Qt source, so in qt directory:
./configure \
-opengl es2 \
-device linux-a20olimex-g++ \
-device-option CROSS_COMPILE=/home/cosik/gcc-linaro-arm-linux-gnueabihf-4.8-2013.09_linux/bin/arm-linux-gnueabihf- \
-sysroot /mnt/a20/ \
-opensource \
-confirm-license \
-optimized-qmake \
-release \
-make libs \
-prefix /opt/qt5.3.2olim2 \
-no-pch \
-nomake examples \
-nomake tests \
-no-xcb \
-eglfs \
-v


By prefix we set Qt installation directory.

After configuration passed, we could see summary in qtbase, this command should show very similar result to my
qtbase/config.summary

Now we are ready for compile and install Qt
make -j 5 && sudo make install

And that's all.

4. Configure Qt Creator
[HowTo] Setting Up Qt Creator for cross compile

5. Test your board
tbd.

References:
Wick Wire blog
Qt development on A20 topic

claudio

"Now you need to open qtbase/mkspecs/devices/linux-a20olimex-g++/qplatformdefs.h in your's favourite editor, replace content of this file with:
qplatformdefs.h"

Are You sure? That is the qmake file not "qplatfordefs.h"

Cosik

Quote from: claudio on October 27, 2014, 03:32:49 PM
"Now you need to open qtbase/mkspecs/devices/linux-a20olimex-g++/qplatformdefs.h in your's favourite editor, replace content of this file with:
qplatformdefs.h"

Are You sure? That is the qmake file not "qplatfordefs.h"

Thank you, fixed ;)

habanas

Hi Cosik

i have some problems with your part 3.
First, I do not get the same file config.summary as you.

Build options:
  Configuration .......... accessibility alsa audio-backend c++11 clock-gettime clock-monotonic compile_examples concurrent cross_compile dbus egl eglfs evdev eventfd fontconfig full-config getaddrinfo getifaddrs glib iconv icu inotify ipv6ifname large-config largefile libudev linuxfb medium-config minimal-config mremap nis no-harfbuzz opengl opengles2 openssl pcre png posix_fallocate qpa qpa reduce_exports reduce_relocations release rpath shared small-config system-freetype system-png system-zlib xinput2 xlib xrender
  Build parts ............  libs
  Mode ................... release
  Using C++11 ............ yes
  Using PCH .............. no
  Target compiler supports:
    iWMMXt/Neon .......... no/auto

Qt modules and options:
  Qt D-Bus ............... yes (loading dbus-1 at runtime)
  Qt Concurrent .......... yes
  Qt GUI ................. yes
  Qt Widgets ............. yes
  Large File ............. yes
  JavaScriptCore JIT ..... yes (To be decided by JavaScriptCore)
  QML debugging .......... yes
  Use system proxies ..... no

Support enabled for:
  Accessibility .......... yes
  ALSA ................... yes
  CUPS ................... no
  FontConfig ............. yes
  FreeType ............... yes (system library)
  Glib ................... yes
  GTK theme .............. no
  HarfBuzz ............... no
  Iconv .................. yes
  ICU .................... yes
  Image formats:
    GIF .................. yes (plugin, using bundled copy)
    JPEG ................. yes (plugin, using bundled copy)
    PNG .................. yes (in QtGui, using system library)
  journald ............... no
  mtdev .................. no
  Networking:
    getaddrinfo .......... yes
    getifaddrs ........... yes
    IPv6 ifname .......... yes
    OpenSSL .............. yes (loading libraries at run-time)
  NIS .................... yes
  OpenGL / OpenVG:
    EGL .................. yes
    OpenGL ............... yes (OpenGL ES 2.x)
    OpenVG ............... no
  PCRE ................... yes (bundled copy)
  pkg-config ............. yes
  PulseAudio ............. no
  QPA backends:
    DirectFB ............. no
    EGLFS ................ yes
    KMS .................. no
    LinuxFB .............. yes
    XCB .................. no
  Session management ..... yes
  SQL drivers:
    DB2 .................. no
    InterBase ............ no
    MySQL ................ no
    OCI .................. no
    ODBC ................. no
    PostgreSQL ........... no
    SQLite 2 ............. no
    SQLite ............... yes (plugin, using bundled copy)
    TDS .................. no
  udev ................... yes
  xkbcommon .............. no
  zlib ................... yes (system library)

NOTE: Qt is using double for qreal on this system. This is binary incompatible against Qt 5.1.
Configure with '-qreal float' to create a build that is binary compatible with 5.1.


Then, when compiling (make -j 5 && sudo make install), I have error at the end .Can they come from my bad config.summary or is it another problem?

aration/qt-everywhere-opensource-src-5.3.2/qtbase/lib -lQt5Gui -lQt5Core -lrt -ldl -lpthread -lGLESv2 -lEGL
ln -s libQt5Widgets.so.5.3.2 libQt5Widgets.so
ln -s libQt5Widgets.so.5.3.2 libQt5Widgets.so.5
ln -s libQt5Widgets.so.5.3.2 libQt5Widgets.so.5.3
rm -f ../../lib/libQt5Widgets.so.5.3.2
mv -f libQt5Widgets.so.5.3.2  ../../lib/
rm -f ../../lib/libQt5Widgets.so
rm -f ../../lib/libQt5Widgets.so.5
rm -f ../../lib/libQt5Widgets.so.5.3
mv -f libQt5Widgets.so ../../lib/
mv -f libQt5Widgets.so.5 ../../lib/
mv -f libQt5Widgets.so.5.3 ../../lib/
make[3]: quittant le répertoire « /home/preparation/qt-everywhere-opensource-src-5.3.2/qtbase/src/widgets »
make[2]: quittant le répertoire « /home/preparation/qt-everywhere-opensource-src-5.3.2/qtbase/src »
make[1]: *** [sub-src-make_first] Erreur 2
make[1]: quittant le répertoire « /home/preparation/qt-everywhere-opensource-src-5.3.2/qtbase »
make: *** [module-qtbase-make_first] Erreur 2


Thank you !

habanas

otherwise,on your part 3
Basic Qt dependencies:

    libfontconfig1-dev
    ibdbus-1-dev
    libfreetype6-dev
    libudev-dev

   
add "l" at ibdbus-1-dev

and
64 bit linux, necessary will installation of 32bit libraries. it's necessary for me to add this

dpkg --add-architecture i386
apt-get install ia32-libs ia32-libs-gtk
apt-get update


before
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 libstdc++6:i386 ia32-libs


for the part 2 Mali driver you can follow :
http://linux-sunxi.org/Mali_binary_driver
http://linux-sunxi.org/Xorg#fbturbo_driver
For EGL/GLES:
https://www.olimex.com/forum/index.php?topic=1910.0

Cosik

Hi,

First of all you need to make configure of Qt on clean directory, so if you have problem you need to remove Qt src directory and extract it one more time.

What is more, you should disable DBUS so add to configure commands -no-dbus. If you still have a problem write here and I will try to help.

habanas

Re,

I retry to configure and compile , finally i have same error at the end of ma compilation .

make[3]: *** [.obj/qeglplatformcontext.o] Erreur 1
make[3]: leaving directory « /home/preparation/qt-everywhere-opensource-src-5.3.2/qtbase/src/platformsupport »
make[2]: *** [sub-platformsupport-make_first] Erreur 2
make[2]: leaving directory « /home/preparation/qt-everywhere-opensource-src-5.3.2/qtbase/src »
make[1]: *** [sub-src-make_first] Erreur 2
make[1]: leaving directory « /home/preparation/qt-everywhere-opensource-src-5.3.2/qtbase »
make: *** [module-qtbase-make_first] Erreur 2



But, my config.summary is different than my first try .


  Build parts ............  libs
  Mode ................... release
  Using C++11 ............ yes
  Using PCH .............. no
  Target compiler supports:
    iWMMXt/Neon .......... no/auto

Qt modules and options:
  Qt D-Bus ............... no
  Qt Concurrent .......... yes
  Qt GUI ................. yes
  Qt Widgets ............. yes
  Large File ............. yes
  QML debugging .......... yes
  Use system proxies ..... no

Support enabled for:
  Accessibility .......... yes
  ALSA ................... yes
  CUPS ................... no
  Evdev .................. yes
  FontConfig ............. no
  FreeType ............... yes (bundled copy)
  Glib ................... no
  GTK theme .............. no
  HarfBuzz ............... no
  Iconv .................. yes
  ICU .................... yes
  Image formats:
    GIF .................. yes (plugin, using bundled copy)
    JPEG ................. yes (plugin, using bundled copy)
    PNG .................. yes (in QtGui, using system library)
  journald ............... no
  mtdev .................. no
  Networking:
    getaddrinfo .......... yes
    getifaddrs ........... yes
    IPv6 ifname .......... yes
    OpenSSL .............. yes (loading libraries at run-time)
  NIS .................... yes
  OpenGL / OpenVG:
    EGL .................. yes
    OpenGL ............... yes (OpenGL ES 2.x)
    OpenVG ............... no
  PCRE ................... yes (bundled copy)
  pkg-config ............. no
  PulseAudio ............. no
  QPA backends:
    DirectFB ............. no
    EGLFS ................ yes
    KMS .................. no
    LinuxFB .............. yes
    XCB .................. no
  Session management ..... yes
  SQL drivers:
    DB2 .................. no
    InterBase ............ no
    MySQL ................ no
    OCI .................. no
    ODBC ................. no
    PostgreSQL ........... no
    SQLite 2 ............. no
    SQLite ............... yes (plugin, using bundled copy)
    TDS .................. no
  udev ................... yes
  xkbcommon .............. no
  zlib ................... yes (system library)


Cosik

Ok, now please run in qt dir make with single thread and return me whole error output, because here are only last lines.



Cosik

Did you try to remove whole qt src directory and run whole again from beginning?

Also are you sure that compilation passed?

EricZ89

Hi Cosik,
Thanks for providing steps on how to correctly cross compile Qt5.

I am using a slight variation to what you have posted, but have found your tutorial more helpful than everything else that I have read on the web. The two variations I am using are:
1) Building Qt in an Open-Embedded environment from the open-source package provided by Qt-project.
2) Building for the TI am335x processor using ARM.

What brought me to your thread on this forum, is that I am able to build every Qt package perfectly, exceptwhen I enable (-eglfs) as a configuration option. The two errors I get during compile are:
1) qtbase-opensource-src-5.3.2/src/corelib/io/qtextstream.h:54:2: error: #error qtextstream.h must be included before any header file that defines Status
qtbase-opensource-src-5.3.2/src/corelib/io/qtextstream.h:80:10: error: expected identifier before 'int'
2) qtbase-opensource-src-5.3.2/src/corelib/io/qurl.h:139:9: error: expected identifier before numeric constant
qtbase-opensource-src-5.3.2/src/corelib/io/qurl.h:139:9: error: expected '}' before numeric constant

I am not a Qt expert, but if I had to point my finger on the problem, it would be the qmake.conf and qplatformdef.h file that are being used by default are incorrect. The Qt open source package by default will use a qmake.conf and qplatformdef.h file that does not include any statements for EGLFS.

The qmake.conf file from the linux-beagleboard-g++ includes items like QT_QPA_DEFAULT_PLATFORM = eglfs,, QMAKE_LIBS_EGL = -lEGL -lIMGegl -lsrv_um, and QMAKE_LIBS_OPENGL_ES2 = -lGLESv2 $${QMAKE_LIBS_EGL}. I know I need these items configured in my qmake.conf if I want to have EGLFS enabled. So I am closely following your steps as this provides me with these configuration statements in qmake.conf that I need.

Looking at your config.summary, I was wondering if you could provide me with a few more details. In my 'Build Options:', I am seeing that egl, egl_x11, and eglfs is present. My configuration is auto_detecting egl_x11. I do not want any x11 option enabled. I am not sure if this is the direct cause of my error, but I was wondering if you knew any tricks how to disable this.

Lastly, in my configure summary, I see two items:
1. Example - Building on: linux-oe-g++ (arm, CPU features: neon)
       or -  Building on: linux-g++ (x86_64, CPU features: mxx sse sse2)
2. Example - Building for: linux-oe-g++ (arm, CPU features: neon)
In your config.summary, I do not see these two items listed. I would like to make sure that my 'Build on/for' configurations are similar to yours.

Thanks for the help!
     


habanas

Quote from: Cosik on December 04, 2014, 06:32:20 PM
Did you try to remove whole qt src directory and run whole again from beginning?

Also are you sure that compilation passed?

i'm not sure to understand, but each time I retry, I remove my "qt-everywhere-opensource-src-5.3.2" directory and I retry step when modify  qeglfshooks_stub.cpp and copy qmakeconf on linux-a20olimex-g++ that's right ?

When you said "Also are you sure that compilation passed?" did talk about ./configure or make or make install ,my compilation has blocked at "make"

EricZ89

Hi Cosik,
On October 10th, you posted on the qt-project forums the same qtextstream.h and qurl.h errors that I am having.
http://qt-project.org/forums/viewthread/48355
No solution was given on that thread. You had posted that you were using linaro v4.7 toolchain.

I notice in this tutorial thread (posted on October 27th), you have updated your linaro toolchain version.
Did switching to linaro v4.8 of the toolchain solve this problem?

Thanks in advance for your help.


Cosik

Hi all,

@habanas please split command, and please show me output of make not make && make install.

@EricZ89 I didn't remember exactly what help. You need to have disabled d-bus, do everything always from begining because it also cause problems. Also you should use one type of graphic support.