Unsolved Cmake (Clion) cant link QT5 UiTools
-
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
-
Since it's a static library you may try to move it after the libs which provide those functions.
-
it seems a magical deletion of the cmake-build-debug folder and rerunning of the cmake file has fixed this
-
@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
-
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.