QtCreator Crosscompiling on iMX6DL not working

Hi,

I have the Colibri iMX6DL running on a Evaluation Board.

Know I tried to set up a delevopment environment on a VM. As host OS I installed Ubuntu 16.04 LTS x64 and followed the steps discribed on the blow link.

everything went fine and at the end I got a QtCreator 5.7.1 running and configured.

But when I tried to compile a project Qt ist complaining about the libQt5Core.so and the libpthread.so in my targets rootfs being incompatible and therefor ist skipping them. Of course the next error is, that Qt cannot find the above mentioned libraries.

I have no clou what went wrong. I set up all the parameters as mentioned in the article and the target root filesystem is pointing to the right direction.

Someone got an idea what’s the problem?
If additional information are required please let me know.

Christoph

Hi

My guess is that you do not compile/link with the cross toolchain or that you do not pass the hard-float flags to the compiler/linker. I.e. some mixup in the kit configuration or the SDK environment script did not get sourced before starting qtcreator from the console where you sourced said environment.

Could you provide the compiler/linker output from Qtcreator’s ‘Compile Output’ window after you cleaned your project and then rebuilt it again?

Max

Of course I can.

07:25:54: Running steps for project Test...
07:25:54: Configuration unchanged, skipping qmake step.
07:25:54: Starting: "/usr/bin/make" 
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/qt5/qmake -spec linux-g++ CONFIG+=debug -o Makefile ../Test/Test.pro
g++ -c -pipe -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_CORE_LIB -I../Test -I. -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/qt5 -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/qt5/QtCore -I. -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/lib/qt5/mkspecs/linux-g++ -o main.o ../Test/main.cpp
g++  -o Test main.o   -L/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/lib -lQt5Core -lpthread 
/usr/bin/ld: skipping incompatible /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/lib/libQt5Core.so when searching for -lQt5Core
Makefile:204: recipe for target 'Test' failed
/usr/bin/ld: cannot find -lQt5Core
/usr/bin/ld: skipping incompatible /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/lib/libpthread.so when searching for -lpthread
collect2: error: ld returned 1 exit status
make: *** [Test] Error 1
07:25:55: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project Test (kit: Toradex Qt Embedded)
When executing step "Make"
07:25:55: Elapsed time: 00:01.

Thanks for helping. I am guessing, that something in the configuration went wrong. For me it sounds like QtCreator is using the wrong compiler, but I cannot figure out why.
I checked the configuration for Qt all over again. I also did all the work again from the beginning, but with the same result. Perhaps I have read over something important, but I could not find it.

Thanks again

Christoph

Hi

You do use the host compiler, e.g. you produce code for x86. That explains why the linker complains that it can not link against an arm binary.

Also I expect to see additional compiler flags which come from the OE SDK settings. E.g. the following is a compiler call from one of my projects:

arm-angstrom-linux-gnueabi-g++  -march=armv7-a -mthumb -mfpu=neon  -mfloat-abi=hard --sysroot=/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi -c -pipe  -O2 -pipe -g -feliminate-unused-debug-types  -O2 -pthread -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/usr/include/gstreamer-1.0 -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/usr/include/glib-2.0 -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/usr/lib/glib-2.0/include -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/usr/include/libxml2 -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/gstreamer-1.0 -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/lib/gstreamer-1.0/include -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/glib-2.0 -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/lib/glib-2.0/include -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/qt5 -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/qt5/QtQuick -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/qt5/QtGui -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/qt5/QtQml -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/qt5/QtNetwork -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/include/qt5/QtCore -I. -I/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi/usr/lib/qt5/mkspecs/linux-oe-g++ -o main.o main.cpp

Did you start qtcreator from a terminal from which you first did source the environment script?

[user@host ~]$ . /usr/local/oecore-x86_64/environment-setup-armv7at2hf-neon-angstrom-linux-gnueabi
[user@host ~]$ qtcreator

Did you go through all the setup steps from here?

Max

Hi again,

thanks for the quick answer. With your question you pointed me into the right direction and I changed the Makefile for the Project manualy.(I actually do not know why Qt is using the wrong compiler in the Makefile, because I did all the steps to configure the QtCreator from the article) After this, the output of the compiler changed to not finding the cstddef file for an include. (Sorry for not giving you the actual compiler output, but I set the VM back to rebuild)

After all I now rebuild everything with the newer Linux version 2.8 and therefore with Qt 5.9.4. Probably It will be done tomorrow morning and I can give an update to the actual situation.

For the newer error, I found a lot about naming the files with .cpp, but I did name all files like this. So it must be something else. If you got any spontaneous ideas why the include is not working, please let me know.

When I look at the environment varibles in the project it looks similar to your compiler output. Normaly I work with cmake, and therefore I will configure cmake with the newer version of Qt and will then test again.

Christoph

As promised I will shortly report how things worked out.

After rebuilding the new toolchain and the new target image, I tested a simple “Hello World” App with cmake. Cmake used the right compiler form the beginning, but did not use the evironment variables I had set earlier. After some research and some trial and error I found out, that I had to tell the compiler explicit where to find the targets root folder (used the --sysroot option from gcc and g++). After I set up this work around everything compiled and was running on the target. My cmake toolchain file looks like the one below.

#the name of the target operating system
set (CMAKE_SYSTEM_NAME Linux)
#which compilers to use for C and C++
set (CMAKE_C_COMPILER arm-angstrom-linux-gnueabi-gcc)
set (CMAKE_CXX_COMPILER arm-angstrom-linux-gnueabi-g++)
#where is the target environment located
# Development-Root
set (CMAKE_FIND_ROOT_PATH /usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi)
#adjust the default behaviour of the FIND_XXX() commands:
#search programs in the host environment
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
#search headers and libraries in the target environment
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
#setting up the compiler options
set (CMAKE_C_FLAGS "-march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi" CACHE STRING "c flags")
set (CMAKE_CXX_FLAGS "-march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard --sysroot=/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi" CACHE STRING "c flags")

In the next step I tried to compile a piece of software which uses the QtWebEngine. It did not work because the SDK does not include the QtWebEngine on default. The QtWebKit is draged in as some dependency but not the QtWebEngine.
I solved the problem by editing the packagegroup-qt5-toolchain-target.bb file, which is part of the meta-qt5 layer as shown below.

diff --git a/recipes-qt/packagegroups/packagegroup-qt5-toolchain-target.bb b/recipes-qt/packagegroups/packagegroup-qt5-toolchain-target.bb
index 234cde8..17fbc26 100755
--- a/recipes-qt/packagegroups/packagegroup-qt5-toolchain-target.bb
+++ b/recipes-qt/packagegroups/packagegroup-qt5-toolchain-target.bb
@@ -105,6 +105,9 @@ RDEPENDS_${PN} += " \
     qtwebchannel-dev \
     qtwebchannel-mkspecs \
     ${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'qtwebchannel-qmlplugins', '', d)} \
+qtwebengine-dev \
+qtwebengine-mkspecs \
+${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'qtwebengine-qmlplugins', '', d)} \
     qtxmlpatterns-dev \
     qtxmlpatterns-mkspecs \
     qttranslations-qtxmlpatterns \

Before rebuilding I noticed, that in the new recipe angstrom-lxde-image from the meta-toradex-demo layer does not include the latest commits on Qt 5.9. So I edit the default.xml from the .repo folder. In detail I changed the revision for meta-qt5.git to the latest commit available from https://github.com/meta-qt5/meta-qt5 for the branch rocko and run repo sync.(Is there any reason for not using the latest commit on this branch?)
At last I had to add the packages for QtWebEngine to be included in the target image to the local.conf and rebuild the image.(Here is something else missing for displaying the web content in a QWidget)

So after an endless building an rebuilding now it works as wanted.

Christoph

hello christoph

for me it sounds like that some libraries (-lQt5core, -lpthread) are not found.