Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved cmake not working with static compiled qt

    General and Desktop
    1
    2
    355
    Loading More Posts
    • 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.
    • M
      Mr Pang last edited by Mr Pang

      I have a custom static compiled qt version installing to /opt/qt593.
      And I found cmake generate wrong linking flags.
      Here is my CMakeLists.txt

      cmake_minimum_required(VERSION 3.0.0)
      
      project(untitled2 VERSION 0.1 LANGUAGES CXX)
      
      set(CMAKE_INCLUDE_CURRENT_DIR ON)
      set(CMAKE_AUTOMOC ON)
      
      set(Qt5Core_DIR "/opt/qt593/lib/cmake/Qt5Core")
      
      find_package(Qt5Core)
      
      add_executable(${PROJECT_NAME} "main.cpp")
      
      target_link_libraries(${PROJECT_NAME} Qt5::Core)
      

      And the final linking command is

      /usr/bin/c++      CMakeFiles/untitled2.dir/main.cpp.o CMakeFiles/untitled2.dir/untitled2_automoc.cpp.o  -o untitled2 -rdynamic /opt/qt593/lib/libQt5Core.a
      

      There are a lot of undefined symbols. It seems that cmake forgets low level system libraries such as glib pthread,etc.

      Any ideas?

      If I switch to qmake, then all is OK.

      1 Reply Last reply Reply Quote 0
      • M
        Mr Pang last edited by

        grep pthread /opt/qt593/lib/pkgconfig/ -rn 
        grep pthread /opt/qt593/lib/cmake/ -rn
        

        And I found that there are lots of matches in pkgconfig, but nothing matches in cmake. So maybe this is a installation bug.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post