This is extended from my previous post: http://kevino.tistory.com/entry/CMakeqt5-Simple-example-for-CMake-QT5-package.


The source files in the above link is intended to be built on Host system and run on local machine. Here I will explain how to cross compile the same source codes  with almost same environment.


In order to develop QT app targeted for Arm embedded system, you need to first prepare Qt5 framework suitable for target board.


For i.MX6 Sabre SDB, refer to the following link: https://community.freescale.com/docs/DOC-94066. If you dont see any error in completing procedures described in the above link, you can find many example binaries created in $(TARGET_rootfs)/opt/qt5/examples and verify by running several examples.


Note. You may not see examples compiled even though you followed all steps. In this case, you can compile the examples manually by running below commands on Host system. If compilation is successful, then verify examples by running those on target board.


$ cd $(QTdir)/qtbase

$ make sub-examples


For now, before running cross compile commands, make sure that the following conditions are all met.


1. Target system is booted via nfs and "/" is mounted on ${TARGET_rootfs) of host system.

2. Qt5 for target board is installed at $(TARGET_rootfs)/opt/qt5 and examples at $(TARGET_rootfs)/opt/qt5/examples.

3. Need to verify whether Qt5 works by running example files and checking QT logo moving in 3D screen.

Target> cd /opt/qt5/examples

Target> ./opengl/hellogl_es2/hellogl_es2


If Qt5 is installed, then lets reuse the project source code which will be converted app for target board.


First we need to inform CMake that we will use cross compile and CMake dev team already made this solution since Cmake 2.6 version. 


For this, we can create a new cmake module similar to the below and remember its path.


Toolchain-freescale-imx6q.cmake


Now you can run cmake with crosscompile options to build the source codes. Assuming the above setup,


$ cd /home/<userid>/utils/ltib/rootfs/root

$ 7za x sample1.7z

$ cd sample1

$ mkdir build

$ cd build

$ cmake -DCMAKE_TOOLCHAIN_FILE=$(PATH_to_)/Toolchain-freescale-imx6q.cmake ..

$ make



Note. While running cmake, if you notice an error "Failed to find GLESv2 in "", then you can fix this error by modifying Qt5GuiConfigExtras.cmake at /home/<userid>/utils/ltib/rootfs/opt/qt5/lib/cmake/Qt5Gui/.


At 50 lines

- _qt5gui_find_extra_libs(OPENGL "GLESv2;GLESv2;EGL;GAL" "" "")

+ _qt5gui_find_extra_libs(OPENGL "GLESv2;GLESv2;EGL;GAL" ${CMAKE_FIND_ROOT_PATH}/usr/lib/ "")


I dont think this patch is good but it works for me so you can use this until official patch is ready. At least Qt 5.1.0 has this problem.


You can examine the exe file in target machine whether this Qt5 app can be run. If successful, now you are ready to develop Qt5 application running on Target board.




Posted by kevino
,