Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt Creator cross compilation kit configuration issue (sysroot, libraries)

Qt Creator cross compilation kit configuration issue (sysroot, libraries)

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • XavierX Offline
    XavierX Offline
    Xavier
    wrote on last edited by
    #1

    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 update qtcreator.sh to set the env variable required for cross compilation
    I configured the debugger to use the gdb of my toolchain.
    I configured the compiler to use the g++ compiler of my toolchain
    I configured qmake to use the qmake of my toolchain.
    I configured a kit using all these programs and specifying my sysroot.
    As I'm cross compiling for a docker image, I kept the device type as Desktop.

    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, the libraries directories are also missing.

    The solution
    To solve this issue, I did add the following parameters to qmake 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 such QMAKE_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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved