Search code examples
c++linuxqt-creatorqmakeqt6

Why QtCreator (qmake) links to different libraries than the ones listed on Kit's Qt version?


I am trying to compile my Qt application and package it for distribution on QtCreator using qmake.

I have a single Kit, configured (whole config details on the table below) to link to the Qt libraries on my home folder, and still, once I compile it, it gives me the system libraries on ldd

How can I force Qt Creator to link with the Qt libraries that I configured it to, and not the system's?

ldd output

$ ldd proprietary_file_reversing2 | grep Qt

libQt6Widgets.so.6 => /lib/x86_64-linux-gnu/libQt6Widgets.so.6 (0x00007fc5863c2000)
libQt6Gui.so.6 => /lib/x86_64-linux-gnu/libQt6Gui.so.6 (0x00007fc585bd9000)
libQt6Core.so.6 => /lib/x86_64-linux-gnu/libQt6Core.so.6 (0x00007fc5856a3000)
libQt6DBus.so.6 => /lib/x86_64-linux-gnu/libQt6DBus.so.6 (0x00007fc584d8a000)

Kit's configuration on QtCreator

ABI: x86-linux-generic-elf-64bit
Source: /home/XXX/Qt/6/6.5.0/gcc_64
mkspec: linux-g++
qmake: /home/XXX/Qt/6/6.5.0/gcc_64/bin/qmake
Version: 6.5.0
QMAKE_SPEC linux-g++
QMAKE_VERSION 3.1
QMAKE_XSPEC linux-g++
QT_HOST_BINS /home/XXX/Qt/6/6.5.0/gcc_64/bin
QT_HOST_DATA /home/XXX/Qt/6/6.5.0/gcc_64
QT_HOST_LIBEXECS /home/XXX/Qt/6/6.5.0/gcc_64/libexec
QT_HOST_LIBS /home/XXX/Qt/6/6.5.0/gcc_64/lib
QT_HOST_PREFIX /home/XXX/Qt/6/6.5.0/gcc_64
QT_INSTALL_ARCHDATA /home/XXX/Qt/6/6.5.0/gcc_64
QT_INSTALL_BINS /home/XXX/Qt/6/6.5.0/gcc_64/bin
QT_INSTALL_CONFIGURATION
QT_INSTALL_DATA /home/XXX/Qt/6/6.5.0/gcc_64
QT_INSTALL_DEMOS /home/XXX/Qt/6/Examples/Qt-6.5.0
QT_INSTALL_DOCS /home/XXX/Qt/6/Docs/Qt-6.5.0
QT_INSTALL_EXAMPLES /home/XXX/Qt/6/Examples/Qt-6.5.0
QT_INSTALL_HEADERS /home/XXX/Qt/6/6.5.0/gcc_64/include
QT_INSTALL_LIBEXECS /home/XXX/Qt/6/6.5.0/gcc_64/libexec
QT_INSTALL_LIBS /home/XXX/Qt/6/6.5.0/gcc_64/lib
QT_INSTALL_PLUGINS /home/XXX/Qt/6/6.5.0/gcc_64/plugins
QT_INSTALL_PREFIX /home/XXX/Qt/6/6.5.0/gcc_64
QT_INSTALL_QML /home/XXX/Qt/6/6.5.0/gcc_64/qml
QT_INSTALL_TESTS /home/XXX/Qt/6/6.5.0/gcc_64/tests
QT_INSTALL_TRANSLATIONS /home/XXX/Qt/6/6.5.0/gcc_64/translations
QT_SYSROOT
QT_VERSION 6.5.0

Solution

  • qmake generates Makefile according to mkspecs, gcc does linking according to instruction in Makefile, inspect Makefile to verify that linking instructions are correct.

    As far as I know binaries does not contain path to linked libraries, only library names, so only way for ldd to know exact path is to look for libraries in $PATH variable, which means that ldd can lie to you if $PATH during compilation is different from the $PATH during executing ldd.

    Another way to put it: when ldd says app is linked to libQt6Widgets.so.6 - it is a fact, but when it says libQt6Widgets.so.6 is /lib/x86_64-linux-gnu/libQt6Widgets.so.6 - it's a guess.