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 (Clion) cant link QT5 UiTools
Forum Updated to NodeBB v4.3 + New Features

Cmake (Clion) cant link QT5 UiTools

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 917 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
    Marc Haubenstock
    wrote on last edited by Marc Haubenstock
    #1

    I have a cmake file for various dummy Qt5 applications.

    cmake_minimum_required(VERSION 3.15)
    project(Qt_demo)
    
    set(CMAKE_CXX_STANDARD 17)
    
    # Tell cmake where Qt is located
    set(Qt5_DIR "~/Code/Cpp/Qt/5.12.6/gcc_64/lib/cmake/Qt5")
    
    #enable mocking compiler
    set(CMAKE_AUTOMOC ON)
    
    #enable ui compiler
    set(CMAKE_AUTOUIC ON)
    
    #enable resources
    set(CMAKE_AUTORCC ON)
    
    
    # Tell cmake to find the modules Qt5Core and Qt5widgets
    find_package(Qt5 COMPONENTS Core Widgets UiTools REQUIRED)
    
    get_target_property(QtUiTools_location Qt5::UiTools LOCATION)
    
    message("${QtUiTools_location}")
    
    
    add_executable(screenshot_demo screenshot/screenshot_main.cpp screenshot/screenshot.cpp)
    # Link the library to the executable
    target_link_libraries(screenshot_demo Qt5::Core Qt5::Widgets)
    
    qt5_add_resources(RC_SRC "application/application.qrc")
    add_executable(application_demo application/main.cpp application/mainwindow.cpp ${RC_SRC})
    qt5_use_modules(application_demo Core Widgets)
    
    qt5_add_resources(CALC_RC_SRC "calculator_builder/calculatorbuilder.qrc")
    add_executable(calculator_builder_demo calculator_builder/main.cpp calculator_builder/calculatorbuilder.cpp ${CALC_RC_SRC})
    target_link_libraries(calculator_builder_demo Qt5::UiTools Qt5::Core Qt5::Widgets )
    

    Furthermore I added the Qt5 desinger as an external tool in clion as per setup

    The first two projects compile and run just fine. However in the last project (calculator builder) I am trying to use UITools which is a Qt5 Addon. When I hit the compile button I get the following error:

    [ 28%] Linking CXX executable calculator_builder_demo
    /home/marc/Code/Cpp/Qt/5.12.6/gcc_64/lib/libQt5UiTools.a(properties.o): In function `QFormInternal::variantToDomProperty(QFormInternal::QAbstractFormBuilder*, QMetaObject const*, QString const&, QVariant const&)':
    /home/qt/work/qt/qttools/src/designer/src/uitools/../lib/uilib/properties.cpp:594: undefined reference to `QString::arg(QLatin1String, int, QChar) const'
    /home/marc/Code/Cpp/Qt/5.12.6/gcc_64/lib/libQt5UiTools.a(formbuilderextra.o): In function `QFormInternal::QFormBuilderExtra::readUi(QIODevice*)':
    /home/qt/work/qt/qttools/src/designer/src/uitools/../lib/uilib/formbuilderextra.cpp:145: undefined reference to `QVersionNumber::fromString(QStringView, int*)'
    /home/qt/work/qt/qttools/src/designer/src/uitools/../lib/uilib/formbuilderextra.cpp:150: undefined reference to `QString::arg(QStringView, int, QChar) const'
    collect2: error: ld returned 1 exit status
    CMakeFiles/calculator_builder_demo.dir/build.make:137: recipe for target 'calculator_builder_demo' failed
    make[3]: *** [calculator_builder_demo] Error 1
    CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/calculator_builder_demo.dir/all' failed
    make[2]: *** [CMakeFiles/calculator_builder_demo.dir/all] Error 2
    CMakeFiles/Makefile2:89: recipe for target 'CMakeFiles/calculator_builder_demo.dir/rule' failed
    make[1]: *** [CMakeFiles/calculator_builder_demo.dir/rule] Error 2
    Makefile:118: recipe for target 'calculator_builder_demo' failed
    make: *** [calculator_builder_demo] Error 2
    

    I am totally lost. Any help would be greatly appreciated

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

      Since it's a static library you may try to move it after the libs which provide those functions.

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

      M 1 Reply Last reply
      0
      • M Offline
        M Offline
        Marc Haubenstock
        wrote on last edited by
        #3

        it seems a magical deletion of the cmake-build-debug folder and rerunning of the cmake file has fixed this

        1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          Since it's a static library you may try to move it after the libs which provide those functions.

          M Offline
          M Offline
          Marc Haubenstock
          wrote on last edited by
          #4

          @Christian-Ehrlicher said in Cmake (Clion) cant link QT5 UiTools:

          Since it's a static library you may try to move it after the libs which provide those functions.

          What would the cmake file look like? I am not a big cmake pro

          Christian EhrlicherC 1 Reply Last reply
          0
          • M Marc Haubenstock

            @Christian-Ehrlicher said in Cmake (Clion) cant link QT5 UiTools:

            Since it's a static library you may try to move it after the libs which provide those functions.

            What would the cmake file look like? I am not a big cmake pro

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Marc-Haubenstock

            What would the cmake file look like?

            try to move it after the libs which provide those functions

            move the QtCore and QtWidget lib before the QtUiTools lib in the cmake command.

            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

            • Login

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