When i try to compile project in CLion with Qt5 lib, take this errors
-
D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function
main': D:/cpp_projects/QtTests/main.cpp:7: undefined reference to
__imp__ZN12QApplicationC1ERiPPci'
D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:9: undefined reference to__imp__ZN7QWidgetC1EPS_6QFlagsIN2Qt10WindowTypeEE' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:10: undefined reference to
__imp__ZN7QWidget12setFixedSizeEii'
D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:12: undefined reference to__imp__ZN11QPushButtonC1ERK7QStringP7QWidget' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:15: undefined reference to
__imp__ZN7QWidget4showEv'
D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:16: undefined reference to__imp__ZN12QApplication4execEv' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to
__imp__ZN11QPushButtonD1Ev'
D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to__imp__ZN7QWidgetD1Ev' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to
__imp__ZN12QApplicationD1Ev'
D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to__imp__ZN11QPushButtonD1Ev' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to
__imp__ZN7QWidgetD1Ev'
D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to__imp__ZN12QApplicationD1Ev' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function
QString::QString(char const*)':
D:/vcpkg/installed/x64-windows/include/qt5/QtCore/qstring.h:833: undefined reference to__imp__ZN7QString16fromAscii_helperEPKci' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function
QWidget::setGeometry(int, int, int, int)':
D:/vcpkg/installed/x64-windows/include/qt5/QtWidgets/qwidget.h:857: undefined reference to__imp__ZN7QWidget11setGeometryERK5QRect' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function
QTypedArrayData<unsigned short>::deallocate(QArrayData*)':
D:/vcpkg/installed/x64-windows/include/qt5/QtCore/qarraydata.h:239: undefined reference to `__imp__ZN10QArrayData10deallocateEPS_yy'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed. -
D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function
main': D:/cpp_projects/QtTests/main.cpp:7: undefined reference to
__imp__ZN12QApplicationC1ERiPPci'
D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:9: undefined reference to__imp__ZN7QWidgetC1EPS_6QFlagsIN2Qt10WindowTypeEE' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:10: undefined reference to
__imp__ZN7QWidget12setFixedSizeEii'
D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:12: undefined reference to__imp__ZN11QPushButtonC1ERK7QStringP7QWidget' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:15: undefined reference to
__imp__ZN7QWidget4showEv'
D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:16: undefined reference to__imp__ZN12QApplication4execEv' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to
__imp__ZN11QPushButtonD1Ev'
D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to__imp__ZN7QWidgetD1Ev' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to
__imp__ZN12QApplicationD1Ev'
D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to__imp__ZN11QPushButtonD1Ev' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to
__imp__ZN7QWidgetD1Ev'
D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: D:/cpp_projects/QtTests/main.cpp:17: undefined reference to__imp__ZN12QApplicationD1Ev' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function
QString::QString(char const*)':
D:/vcpkg/installed/x64-windows/include/qt5/QtCore/qstring.h:833: undefined reference to__imp__ZN7QString16fromAscii_helperEPKci' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function
QWidget::setGeometry(int, int, int, int)':
D:/vcpkg/installed/x64-windows/include/qt5/QtWidgets/qwidget.h:857: undefined reference to__imp__ZN7QWidget11setGeometryERK5QRect' D:\CLion 2024.1.2\bin\mingw\bin/ld.exe: CMakeFiles/QtTests.dir/main.cpp.obj: in function
QTypedArrayData<unsigned short>::deallocate(QArrayData*)':
D:/vcpkg/installed/x64-windows/include/qt5/QtCore/qarraydata.h:239: undefined reference to `__imp__ZN10QArrayData10deallocateEPS_yy'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed. -
I found a solution to the problem, it only works if you switch the CMake-profile Toolchain to Visual Studio.
and Generator to Visual Studio 17 2022.