How to build QT5 for UDOO
Hi guys, in this tutorial we’re going to explain you how to build Qt5 with Qt3D.
Note: this guide doesn’t work on the official UDOObuntu OS at the moment, but only in the previous official OS versions.
We will perform the following Qt5 building steps below on the host machine (from 1 to 8 steps).
First, we have to get Qt source code, the freescale toolchain and UDOO file system.
If you need to install git, run from a terminal emulator:
sudo apt-get install git
We are going to create a directory where we’ll put Qt5 source code and toolchain. To do so, run from the terminal:
mkdir Qt5_build
You can choose a different name if you like.
From now on this directory will be our working one.
1. To get freescale toolchain run this command:
Note: we use Qt5_build$ as the shell prompt example, don’t type it.
Qt5_build$ git clone https://github.com/embest-tech/fsl-linaro-toolchain.git
2. You’ll find the File System of Ubuntu 11.10 or 12.04 in our downloads page.
Since you got a filesystem.tar.gz, you can extract it in our working directory. Run:
Qt5_build$ sudo tar xvzf "path-to-ubuntu-filesystem".tar.gz Qt5_build$ sudo chown -R "username" "ubuntu filesystem directory name"
As target filesystem you can use your filesystem on the micro SD card for UDOO board, that you created before. On the host machine you will find it under the /media directory.
3. Due to some issues (the Workaround is in progress), we will use EGL and OpenGL ES accelerated for framebuffer not for X11.
We have to adjust the following symbolic links:
Qt5_build$ cd /path/to/filesystem directory/usr/lib lib$ sudo rm libEGL.so lib$ sudo rm libEGL.so.1 lib$ sudo rm libGAL.so lib$ sudo ln -s libEGL-fb.so libEGL.so lib$ sudo ln -s libEGL-fb.so libEGL.so.1 lib$ sudo ln -s libGAL-fb.so libGAL.so lib$ cd /path/to/Qt5_build
4. Getting Qt5 with Qt 3D source code
4.1. To download the git repository for Qt5 run the following command:
Qt5_build$ git clone git://gitorious.org/qt/qt5.git qt5
4.2. To switch to a release branch:
Qt5_build$ cd qt5 qt5$ git checkout release
4.3 To download the git repository for Qt 3D run:
qt5$ git clone git://gitorious.org/qt/qt3d.git qt3d
4.4 Then we have to run the init-repository script to download all the source code for Qt5 with Qt 3D (It will take some time):
qt5$ ./init-repository
5. Now we are going to make some modification in qmake.conf file:
qt5$ gedit qtbase/mkspecs/devices/linux-imx6-g++/qmake.conf
We define the following variables in this way:
QMAKE_INCDIR += $$[QT_SYSROOT]/usr/include $$[QT_SYSROOT]/usr/include/arm-linux-gnueabi QMAKE_LFLAGS += -Wl,-rpath-link,$$[QT_SYSROOT]/usr/lib -Wl,-rpath-link,$$[QT_SYSROOT]/usr/lib/arm-linux-gnueabi
The rest of qmake.conf file is left as in original.
6. We have to define the configure option. For the full list of options you can run:
$ ./configure -help
The essential options are:
[checklist icon=”check” iconcolor=”#ffffff” circle=”yes”]
- -prefix – define “path-to-installation-directory”. We use /opt/qt5 as installation directory.
- -device – a specific device, in our case is the imx6.
- -device-option – sets additional qmake variables. The -device-option CROSS_COMPILE=”path-to-toolchain” provides the environment variable, CROSS_COMPILE, as needed by the device
- -sysroot – sets “path-to-our-target-filesystem” for headers and libraries.
- -no-gcc-sysroot – used to avoid the compiler to point at the sysroot directory structure, as it misses the basic building blocks.
- Make sure to include -no-pch (due to an issue), -opengl es2, -no-opengl(as it is desktop version).
[/checklist]
We tested the following configure options, so we suggest you to use them for your first building test.
You can run configure with these options:
qt5$ ./configure -prefix /opt/qt5 -make libs -no-pch -no-opengl -device imx6 -device-option CROSS_COMPILE=/path/to/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi- -no-largefile -opengl es2 -qt-zlib -qt-libpng -qt-libjpeg -no-nis -no-cups -gui -make examples -sysroot /path/to/target filesystem -no-gcc-sysroot -opensource -confirm-license -qreal float -v
If you need to do some modifications to the configure options, clean first, running this command:
qt5$ git submodule foreach --recursive "git clean -dfx"
After successful configuration have a look at “Configure summary” where you should find “OpenGL …yes (OpenGL ES 2.x)”.
7. Now let’s run the make command:
qt5$ make
This compilation may take some time.
8. Once everything was built, run “make install”.
Create the install directory on the host machine:
qt5$ sudo mkdir /opt/qt5 qt5$ sudo chown -R "username" /opt/qt5
and the install directory in the target filesystem:
qt5$ sudo mkdir /path/to/target filesystem/opt/qt5 qt5$ sudo chown -R "username" /path/to/target filesystem/opt/qt5 qt5$ make install
If everything worked fine the Qt5 will be installed in our “target filesystem”/opt/qt5 directory.
Now we need to perform on target.
Note: If you have the target filesystem in the working directory, you have to copy qt5 directory from there to the rootfs on your micro SD card for UDOO board in the same path, as so /opt/qt5. Pay attention to the ownerships for that directory, it is better qt5 directory has user (ubuntu) as the owner and root as group.
To visualize them you can use this command:
$ ls -l /opt/qt5
To change the ownership use the following command:
$ sudo chown -R ubuntu:root /opt/qt5
9. To tell the dynamic linker where to search the appropriate libraries run this script:
$ sudo /opt/gpulink-fb.sh
Note: If you need to turn again to x11 version of the libraries run:
$ sudo /opt/gpulink-x11.sh
10. Now we can test some of the Qt examples:
$ /opt/qt5/examples/qt3d/monkeygod $ /opt/qt5/examples/qt3d/shaders $ /opt/qt5/examples/qt3d/basket_qml $ /opt/qt5/examples/qt3d/moon $ /opt/qt5/examples/qt3d/cubehouse $ /opt/qt5/examples/qt3d/solarsystem
For more details:
http://qt-project.org/wiki/i.MX-6
http://qt-project.org/wiki/Building_Qt_5_from_Git
In our next tutorial we’ll explain how to create a simple Qt 3D application.
Your comments and feedback will be very appreciated.
Enjoy.
Submit a comment