Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtCreator with CMake tries to link the wrong set of Qt libraries. CMake alone works fine.
Forum Updated to NodeBB v4.3 + New Features

QtCreator with CMake tries to link the wrong set of Qt libraries. CMake alone works fine.

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
qt5.15.1cmakecutelystubuntu 20.04
5 Posts 2 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.
  • F Offline
    F Offline
    Fahad-Cattchi
    wrote on last edited by
    #1

    I have a Cutelyst application (which is part of a larger project) that I'm trying to get to run. It works fine if I build and run using CMake alone. But if I try to run from QtCreator, or run the exe that QtCreator built, it tries to mix the 5.12.8 libs from my system at /usr/lib/x86_64-linux-gnu/ with the 5.15.1 libs from my kit at /home/fahad/Qt/5.15.1/gcc_64/lib/.

    Here's my CMakeLists.txt file for the Cutelyst app:

    cmake_minimum_required(VERSION 3.19)
    cmake_policy(SET CMP0048 NEW)
    
    project(ServerCutelyst VERSION 0.0.1)
    
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    
    add_executable(ServerCutelyst
        src/main.cpp
        src/root.cpp
        src/ServerCutelyst.cpp
        src/root.h
        src/ServerCutelyst.h
    )
    
    find_package(Cutelyst3Qt5 REQUIRED)
    find_package(Qt5 COMPONENTS Core Network REQUIRED)
    
    target_link_libraries(ServerCutelyst PRIVATE
        Cutelyst::Core
        Cutelyst::Server
        Cutelyst::Session
        Qt5::Core
        Qt5::Network)
    
    install(TARGETS ServerCutelyst RUNTIME DESTINATION .)
    

    I tried adding:

    SET(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath -Wl,/home/fahad/Qt/5.15.1/gcc_64/lib/")
    

    to the CMakeLists.txt file force it to link with the 5.15.1 libs, but that did not fix the issue.

    The specific errors I'm getting when I try to run directly from QtCreator are:

    /home/fahad/Project/build-Project-Desktop-Debug/bin/ServerCutelyst: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.15' not found (required by /home/fahad/Project/build-Project-Desktop-Debug/bin/ServerCutelyst)
    

    And when I try to run the exe that QtCreator produced on build:

    144607:144607 default[fatal] Cannot mix incompatible Qt library (5.12.8) with this library (5.15.1)
    

    How can I force it to build and link with only the 5.15.1 libraries when using QtCreator?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Use the correct Kit with the correct Qt version: https://doc.qt.io/qtcreator/creator-project-qmake.html

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Fahad-Cattchi
        wrote on last edited by Fahad-Cattchi
        #3

        I think that I am using the correct version in my kit.

        b062e6e8-b5fe-4161-abc6-1fbd2963030e-image.png

        0960a20d-b4f9-4db5-8512-d164d7f6fce0-image.png

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Remove the build dir, make sure the kit really points to the correct Qt version.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • F Offline
            F Offline
            Fahad-Cattchi
            wrote on last edited by
            #5

            I haven't solved the problem yet, but I know what caused it.

            QtCreator is doing what it's supposed to, that is, finding the 5.15.1 libraries correctly.

            My problem is that my Cutelyst version was built with Qt 5.12.8. CMake automatically found and used the Qt 5.12.8 libraries I have installed, which allowed the version built with only CMake to run correctly.

            So, I built a Cutelyst version manually using the 5.15.1 libraries instead. I'm having trouble getting CMake to detect that version, but that's a separate issue, so I'll close this one.

            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