Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. cmake not working with static compiled qt
Forum Updated to NodeBB v4.3 + New Features

cmake not working with static compiled qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 481 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.
  • M Offline
    M Offline
    Mr Pang
    wrote on last edited by Mr Pang
    #1

    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
    0
    • M Offline
      M Offline
      Mr Pang
      wrote on last edited by
      #2
      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
      0

      • Login

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