Cross-compiling Qt 5.0 for iMX6 on Phytec development board
-
Hi,
I just received my dev board for Phytec and installed the development kit on Ubuntu 12.04. The provided pre-installed libraries (Qt 4.7.4) work fine : I'm able to compile the example program and run it on the target.
I want now compile and use Qt5.
I downloaded the sources and I ran the following configure command, as said in the Raspberry Pi tutorial and in the qmake.conf file into the mkspecs linux-imx6-g++ directory :
@./configure -opensource -confirm-license -opengl es2 -device linux-imx6-g++ -qt-xcb -qpa xcb -v -device-option CROSS_COMPILE=/opt/OSELAS.Toolchain-2011.11.1/arm-cortexa9-linux-gnueabi/gcc-4.6.2-glibc-2.14.1-binutils-2.21.1a-kernel-2.6.39-sanitized/bin/arm-cortexa9-linux-gnueabi- -sysroot /opt/PHYTEC_BSPs/BSP-Phytec-phyFLEX-i.MX6-PD12.0.3/platform-mx6/root -no-gcc-sysroot -prefix /usr/local/Qt-5.0.0/Qt-imx6-1 -optimized-qmake -reduce-relocations -reduce-exports -make libs@
As I don't have enough headers in the path provided, I modified the qmake.conf as following :
@#qmake configuration for the Freescale iMX6 boards (single, dual and quad)
This mkspec is based and tested on the ltib-source-release 3.0.15
Building ltib including glib, gpu-drivers and what ever you want to use (e.g. dbus or fontconfig)
This mkspec is tested with a framebuffer (eglfs) configuration (not testes with X11)
A typical configure line looks like:
/home/tsenyk/qt5/qt5/configure -opensource -confirm-license -make libs -device imx6 \
-device-option CROSS_COMPILE=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi- \
-sysroot <path-to-your-ltib-install>/rootfs -no-gcc-sysroot \
-prefix /usr/local/Qt-5.0.0/Qt5-imx6-1
NOTE: currently ltib doesn't produce a proper staging/sysroot-filessystem.
If gcc's --sysroot is used, the toolchain doesn't find basic binaries (e.g. crt1.o),
therefore you have to pass -no-gcc-sysroot to configure if you pass -sysroot to configure!
include(../common/linux_device_pre.conf)
EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/qeglfshooks_imx6.cpp
QMAKE_INCDIR += $$[QT_SYSROOT]/usr/include /opt/OSELAS.Toolchain-2011.11.1/arm-cortexa9-linux-gnueabi/gcc-4.6.2-glibc-2.14.1-binutils-2.21.1a-kernel-2.6.39-sanitized/sysroot-arm-cortexa9-linux-gnueabi/usr/include
QMAKE_LIBDIR += $$[QT_SYSROOT]/usr/lib /opt/OSELAS.Toolchain-2011.11.1/arm-cortexa9-linux-gnueabi/gcc-4.6.2-glibc-2.14.1-binutils-2.21.1a-kernel-2.6.39-sanitized/sysroot-arm-cortexa9-linux-gnueabi/usr/libQMAKE_LIBS_EGL += -lEGL
QMAKE_LIBS_OPENGL_ES2 += -lGLESv2 -lEGL -lGAL
QMAKE_LIBS_OPENVG += -lOpenVG -lEGL -lGALQMAKE_LFLAGS += -Wl,-rpath-link,$$[QT_SYSROOT]/usr/lib
IMX6_CFLAGS = -O2 -march=armv7-a -mfpu=neon -DLINUX=1 -DEGL_API_FB=1
QMAKE_CFLAGS_RELEASE += $$IMX6_CFLAGS
QMAKE_CXXFLAGS_RELEASE += $$IMX6_CFLAGSinclude(../common/linux_device_post.conf)
load(qt_config)@
The configuration went well, but when I type make, I finally get an error :
@/opt/OSELAS.Toolchain-2011.11.1/arm-cortexa9-linux-gnueabi/gcc-4.6.2-glibc-2.14.1-binutils-2.21.1a-kernel-2.6.39-sanitized/bin/arm-cortexa9-linux-gnueabi-g++ -c -include .pch/release-shared/Qt5Core -pipe -mfloat-abi=softfp -O2 -O2 -march=armv7-a -mfpu=neon -DLINUX=1 -DEGL_API_FB=1 -std=c++0x -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -D_REENTRANT -fPIC -DQT_NO_LIBUDEV -DQT_NO_USING_NAMESPACE -DQT_BUILD_CORE_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DPCRE_HAVE_CONFIG_H -DHB_EXPORT=Q_CORE_EXPORT -DQT_CORE_LIB -DQT_NO_DEBUG -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I../../mkspecs/devices/linux-imx6-g++ -I. -I../../include -I../../include/QtCore -I../../include/QtCore/5.0.0 -I../../include/QtCore/5.0.0/QtCore -Iglobal -I../3rdparty/zlib -I../3rdparty/pcre -I../3rdparty/md5 -I../3rdparty/md4 -I.moc/release-shared -I/opt/PHYTEC_BSPs/BSP-Phytec-phyFLEX-i.MX6-PD12.0.3/platform-mx6/root/usr/include -I/opt/OSELAS.Toolchain-2011.11.1/arm-cortexa9-linux-gnueabi/gcc-4.6.2-glibc-2.14.1-binutils-2.21.1a-kernel-2.6.39-sanitized/sysroot-arm-cortexa9-linux-gnueabi/usr/include -o .obj/release-shared/qcryptographichash.o tools/qcryptographichash.cpp
In file included from tools/qcryptographichash.cpp:48:0:
../../include/QtCore/../../src/corelib/global/qendian.h: In function 'void sha1ProcessChunk(Sha1State*, const unsigned char*)':
../../include/QtCore/../../src/corelib/global/qendian.h:293:12: error: invalid 'asm': invalid operand for code 'w'
../../include/QtCore/../../src/corelib/global/qendian.h:293:12: error: invalid 'asm': invalid operand for code 'w'
{standard input}: Assembler messages:
{standard input}:2270: Error: bad instructionrorw $8,' {standard input}:2270: Error: bad instruction
rorl $16,r2'
{standard input}:2270: Error: bad instruction `rorw $8,'
make[2]: *** [.obj/release-shared/qcryptographichash.o] Erreur 1
make[2]: quittant le répertoire « /home/bruno/qt-everywhere-opensource-src-5.0.0/qtbase/src/corelib »
make[1]: *** [sub-corelib-make_first] Erreur 2
make[1]: quittant le répertoire « /home/bruno/qt-everywhere-opensource-src-5.0.0/qtbase/src »
make: *** [sub-src-make_first] Erreur 2
@I checked and the references to this code are present into byteswap.h, that is available into the paths I provided.
Is it a problem with the headers, or with the cross-compiler ? -
I finally managed to get it build with the following configure options :
@./configure -opensource -confirm-license -opengl es2 -device linux-imx6-g++ -directfb -eglfs -v -device-option CROSS_COMPILE=/opt/OSELAS.Toolchain-2012.12.0/arm-cortexa9-linux-gnueabihf/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/bin/arm-cortexa9-linux-gnueabihf- -no-gcc-sysroot -prefix /usr/local/Qt-5.0.0/Qt-imx6-1 -optimized-qmake -reduce-relocations -reduce-exports -make libs -no-pch
@The trick was to set correctly the headers into the qmake.conf file into the qtbase/mkspecs/devices/linux-imx6-g++ folder.
@#
qmake configuration for the Freescale iMX6 boards (single, dual and quad)
This mkspec is based and tested on the ltib-source-release 3.0.15
Building ltib including glib, gpu-drivers and what ever you want to use (e.g. dbus or fontconfig)
This mkspec is tested with a framebuffer (eglfs) configuration (not testes with X11)
A typical configure line looks like:
/home/tsenyk/qt5/qt5/configure -opensource -confirm-license -make libs -device imx6 \
-device-option CROSS_COMPILE=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi- \
-sysroot <path-to-your-ltib-install>/rootfs -no-gcc-sysroot \
-prefix /usr/local/Qt-5.0.0/Qt5-imx6-1
NOTE: currently ltib doesn't produce a proper staging/sysroot-filessystem.
If gcc's --sysroot is used, the toolchain doesn't find basic binaries (e.g. crt1.o),
therefore you have to pass -no-gcc-sysroot to configure if you pass -sysroot to configure!
include(../common/linux_device_pre.conf)
EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/qeglfshooks_imx6.cpp
DISTRO_OPTS += hard-float
#QMAKE_INCDIR += $$[QT_SYSROOT]/usr/include
#QMAKE_LIBDIR += $$[QT_SYSROOT]/usr/libQMAKE_INCDIR = /home/bruno/BSP/BSP-Phytec-phyFLEX-i.MX6-PD12.0.3/platform-mx6/sysroot-target/include /home/bruno/BSP/BSP-Phytec-phyFLEX-i.MX6-PD12.0.3/platform-mx6/sysroot-target/usr/include
QMAKE_LIBDIR = /home/bruno/BSP/BSP-Phytec-phyFLEX-i.MX6-PD12.0.3/platform-mx6/sysroot-target/lib /home/bruno/BSP/BSP-Phytec-phyFLEX-i.MX6-PD12.0.3/platform-mx6/sysroot-target/usr/libQMAKE_INCDIR_OPENGL_ES2 = /opt/OSELAS.Toolchain-2012.12.0/arm-cortexa9-linux-gnueabihf/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/usr/include
QMAKE_INCDIR_EGL = /opt/OSELAS.Toolchain-2012.12.0/arm-cortexa9-linux-gnueabihf/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/usr/include
QMAKE_LIBDIR_OPENGL_ES2 = /opt/OSELAS.Toolchain-2012.12.0/arm-cortexa9-linux-gnueabihf/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/usr/lib
QMAKE_LIBDIR_EGL = /opt/OSELAS.Toolchain-2012.12.0/arm-cortexa9-linux-gnueabihf/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/usr/libQMAKE_LIBS_EGL += -lEGL -lGAL
QMAKE_LIBS_OPENGL_ES2 += -lGLESv2 -lEGL -lGAL
QMAKE_LIBS_OPENVG += -lOpenVG -lEGL -lGALQMAKE_LFLAGS += -Wl,-rpath-link,$$[QT_SYSROOT]/usr/lib
IMX6_CFLAGS = -O2 -march=armv7-a -mfpu=neon -DLINUX=1 -DEGL_API_FB=1
QMAKE_CFLAGS_RELEASE += $$IMX6_CFLAGS
QMAKE_CXXFLAGS_RELEASE += $$IMX6_CFLAGSinclude(../common/linux_device_post.conf)
load(qt_config)@
And to set independently the paths to OpenGL libraries, as the headers and libraries are not into the same locations, due to the incomplete OSELAS toolchain (I had to copy the OpenGL libs and headers from the LTIB Linaro toolchain provided by Freescale).
Now I have to figure out how to build other modules, as the documentation only says that it's possible to do so, not how !
-
I found the solution here : http://gpupowered.org/node/8
bq.
After configure, make && make install are to be done. This is important, as qmake needs to be in the install path.Steps to build Qt3D :
To build Qt3D, in addition to qtbase also need to build the below:
qtjsbackend (has v8)
qtdeclarative
qt3dTo build the above, enter the directory, then perform (assuming qmake is in the path as specified earlier)
$ qmake && make && make install
bq.It seems to work.
-
And it works better that way : http://www.mail-archive.com/interest@qt-project.org/msg04497.html
bq. Although I didn't find out why it compiled just once (and for sure I
didn't change some qt.conf for it :-) ), I even better understood qmake
and found out that paths configured in qt/qtbase/bin/qt.conf were
responsible for qmake to read the wrong module mkspecs. I've no idea how
Prabindh from TI managed to compiled it this way as I don't see how qt5
can be configured correctly via --prefix, but without changing this qt.conf.Some more details for those who bump into the same problem... In case
you want to install qt5 to /foo/usr simply set qt/qtbase/bin/qt.conf
also to it:[EffectivePaths]
Prefix=/foo/usr -
In order to test QML and OpenGL, I built the example "Samegame". I had some issue with the Makefile but I deleted the references to /usr/lib (on the host).
I copied the Qt5 libraries (don't modify the path and directories) on my dev board root filesystem and tried to execute the program. I got these error messages, but I think they concern the GPU binaries.
@root@phyFLEX-i:/root/samegame-build-IMX6_Qt5-Default_build_Release ./samegame
QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv_open failed
Qml debugging is enabled. Only use this in a safe environment!
QIconvCodec::convertToUnicode: using Latin-1 for conversion, iconv_open failed
evdevtouch: Using device /dev/input/event0
min X: 0 max X: 0
min Y: 0 max Y: 0
min pressure: 0 max pressure: 255
device name: stmpe-ts
Protocol type A
QOpenGLShader::compile(Fragment): (5:0) : error : syntax error*** Problematic Fragment shader source code ***
#ifndef GL_FRAGMENT_PRECISION_HIGH
#define highp mediump
#endif
uniform sampler2D texture;
varying highp vec2 textureCoord;
void main() {
gl_FragColor = texture2D(texture, textureCoord).bgra;
}
QOpenGLShader::link: "No fragment shader attached."
QOpenGLShaderProgram::attributeLocation( vertexCoordEntry ): shader program is not linked
QOpenGLShaderProgram::attributeLocation( textureCoordEntry ): shader program is not linked
QOpenGLShader::link: "No fragment shader attached."
QOpenGLShader::link: "No fragment shader attached."
@ -
HI,
This is fixed in the latest BSP release, see this thread:
https://lists.yoctoproject.org/pipermail/meta-freescale/2013-January/000925.html -
Hi,
I rechecked the libraries I was using and I found the bug : they were not copied into the right filesystem. Now I'm facing an other problem, while trying to execute hellogl :
@root@xap:/root/hellogl_es2-build-IMX6_Qt5-Debug ./hellogl_es2
QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv_open failed
QIconvCodec::convertToUnicode: using Latin-1 for conversion, iconv_open failed
evdevtouch: Using device /dev/input/event0
min X: 0 max X: 0
min Y: 0 max Y: 0
min pressure: 0 max pressure: 255
device name: stmpe-ts
Protocol type A
This plugin does not support propagateSizeHints()
This plugin does not support setParent!
This plugin does not support setParent!
This plugin does not support setParent!
This plugin does not support setParent!
This plugin does not support setParent!
This plugin does not support setParent!
This plugin does not support setParent!
This plugin does not support propagateSizeHints()
QOpenGLContext::swapBuffers() called with non-opengl surface
QOpenGLContext::swapBuffers() called with non-opengl surface
QOpenGLContext::swapBuffers() called with non-opengl surface
QOpenGLContext::swapBuffers() called with non-opengl surface
QOpenGLContext::swapBuffers() called with non-opengl surface
QOpenGLContext::swapBuffers() called with non-opengl surface
QOpenGLContext::swapBuffers() called with non-opengl surface
QOpenGLContext::swapBuffers() called with non-opengl surface @All I see on the screen is the frame rate, about 100 fps, white on black.
-
I tried to get Qt DirectFB support but there is no way to get it supported.
I don't understand because the configure program doesn't seem to try to compile it but always return
@DirectFB support ....... no@Here is my new configure options :
@./configure -opensource -confirm-license -opengl es2 -device linux-imx6-g++ -directfb -v -device-option CROSS_COMPILE=/opt/OSELAS.Toolchain-2012.12.0/arm-cortexa9-linux-gnueabihf/gcc-4.7.3-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/bin/arm-cortexa9-linux-gnueabihf- -no-gcc-sysroot -prefix /usr/local/Qt-5.0.1/Qt-imx6-1 -optimized-qmake -reduce-relocations -reduce-exports -make libs -no-pch -lz -lglib-2.0 -ldirect -ldirectfb -lfusion@