Important: Please read the Qt Code of Conduct -

Makefile cannot find libQtCore while libQt5Core exist

  • Hello,
    I compiled Qt5 to use on a debian docker. I packaged the install folder and installed it in /usr/local/lib and i had that path to the ld path (so I have all the usual in the ld file, when I try that with g++ -lQt5Core it works and find the lib).

    I have a CMake also for the project using Qt on the docker that find the Qt5 Components just fine, I also have a target_link_libaries set with the correct lib (including Qt) so my cmake works fine.
    After that though, when I try the make command, my project fails pretty quickly saying that ld couldn't find -lQtCore

    I don't understand what I did wrong. Why cmake gives me a Makefile with -lQtCore when it should have been -lQt5Core ?

    Thanks for your help

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you sure cmake does not find your distribution Qt 4 libraries rather than your self built Qt 5 ?

    How are you doing the find with cmake ?

  • Hi, thank you,
    Sorry for the late reply, I had covid

    I use a cmake with the likes of

    find_package(Qt5 COMPONENTS Widgets REQUIRED)

    with all the required components and then

    target_link_libraries(application Qt5::Widgets)

    And since it's in a docker run, I made sure (I hope) that there was no Qt4 install. I will double check just in case of some forgotten apt-get in the dockerfile.

  • I fixed it, I had other CMakeFiles that were not updated and still had QtCore in the target_link_libraries.

Log in to reply