Qt Creator cross compilation kit configuration issue (sysroot, libraries)
-
Hello,
I'm using Yocto and configures a dedicated kit to the cross compilation environment.
When I tried to compile a "helloworld" program I had a linking issue.
I found a solution but I'm not sure I used the good way to solve my issue and I wonder if somebody in this forum can explain me why I experience such an issue and how to fix it properly.QtCreator configuration
I did compile qt5 toolchain with yocto (meta-toolchain-qt5
) and install it.
I did updateqtcreator.sh
to set the env variable required for cross compilation
I configured the debugger to use thegdb
of my toolchain.
I configured the compiler to use theg++
compiler of my toolchain
I configured qmake to use theqmake
of my toolchain.
I configured a kit using all these programs and specifying mysysroot
.
As I'm cross compiling for a docker image, I kept the device type asDesktop
.The issue
When I tried to compile my "helloworld" program (named QtVersion and writing the version of Qt in a console), the linker is giving me the following error.g++ -o QtVersion main.o -lQt5Core -lpthread /usr/bin/ld: cannot find -lQt5Core
In this command, few thing are missing for cross compilation.
sysroot
is not present, thelibraries directories
are also missing.The solution
To solve this issue, I did add the following parameters toqmake
command executed by my project:QMAKE_LIBS+="-L/usr/lib -L/lib" QMAKE_LFLAGS+="-Wl,-O1 -Wl,-z,origin -Wl,-rpath,\$$ORIGIN -Wl,-rpath,/usr/lib -Wl,-rpath,/lib --sysroot=/data/Yocto/sdk/krogoth/dockerguest/2.1/sysroots/core2-64-poky-linux"
Now, the compilation and execution are working fine.
The questions
Whay should I had to specify suchQMAKE_VARIABLE
to make it work?
Shouldn't it be done automatically?
The compilation was working but not the linking, why?Here is the compilation command:
g++ -c -pipe -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_CORE_LIB -I../QtVersion -I. -isystem /data/Yocto/sdk/krogoth/dockerguest/2.1/sysroots/core2-64-poky-linux/usr/include/qt5 -isystem /data/Yocto/sdk/krogoth/dockerguest/2.1/sysroots/core2-64-poky-linux/usr/include/qt5/QtCore -I. -I/data/Yocto/sdk/krogoth/dockerguest/2.1/sysroots/core2-64-poky-linux/usr/lib/qt5/mkspecs/linux-g++ -o main.o ../QtVersion/main.cpp
I hope you will be able to help me to understand why I experienced such an issue and how to solve it cleanly.
Thx and rgds,
Xavier