CMake Undefined Reference to `QGraphicsItem:: ...
-
Hello,
I am fairly new to CMake and C++ development and I am trying to convert a Qt Creator project to CMake so that I can use CLion for development, however I am getting an error when trying to build the project.
From what I understand the project uses
Qt5::Core
,Qt5::Gui
andQt5::Widgets
and contains no.qrc
files.The errors returned are of the form:
CMakeFiles\zeus.dir/objects.a(TileView.cpp.obj):TileView.cpp:(.rdata$_ZTV8TileView[__ZTV8TileView]+0x8c): undefined reference to `QGraphicsItem::itemChange(QGraphicsItem::GraphicsItemChange, QVariant const&)' CMakeFiles\zeus.dir/objects.a(TileView.cpp.obj):TileView.cpp:(.rdata$_ZTV8TileView[__ZTV8TileView]+0x90): undefined reference to `QGraphicsItem::supportsExtension(QGraphicsItem::Extension) const' CMakeFiles\zeus.dir/objects.a(TileView.cpp.obj):TileView.cpp:(.rdata$_ZTV8TileView[__ZTV8TileView]+0x94): undefined reference to `QGraphicsItem::setExtension(QGraphicsItem::Extension, QVariant const&)' CMakeFiles\zeus.dir/objects.a(TileView.cpp.obj):TileView.cpp:(.rdata$_ZTV8TileView[__ZTV8TileView]+0x98): undefined reference to `QGraphicsItem::extension(QVariant const&) const' CMakeFiles\zeus.dir/objects.a(TileView.cpp.obj): In function `ZN8TileViewD1Ev': .../src/viewer/TileView.hpp:18: undefined reference to `_imp___ZN13QGraphicsItemD2Ev' CMakeFiles\zeus.dir/objects.a(main.cpp.obj): In function `main': .../main.cpp:7: undefined reference to `_imp___ZN12QApplicationC1ERiPPci' .../src/main.cpp:11: undefined reference to `_imp___ZN7QWidget13showMaximizedEv' .../src/main.cpp:13: undefined reference to `_imp___ZN12QApplication4execEv' .../src/main.cpp:7: undefined reference to `_imp___ZN12QApplicationD1Ev' .../src/main.cpp:7: undefined reference to `_imp___ZN12QApplicationD1Ev'
and there is many more printed out!
The original
.pro
file is located here.
My attempt at a CMake file is located here. -
What compiler do you use and what Qt version (and for which compiler) did you download Qt?
-
I am using the Windows MinGW64 i686-8.1.0-posix-dwarf-rt_v6-rev0 compiler and have installed Qt 5.15.2.
I also have these variables passed in to Cmake
-DQt5_DIR=C:\Qt\5.15.2\mingw81_64\lib\cmake\Qt5 -DCMAKE_PREFIX_PATH=C:\Qt\5.15.2\mingw81_64\lib\cmake
and linking the required
yaml-cpp
library with the build option-lyaml-cpp
. -
@Karlos said in CMake Undefined Reference to `QGraphicsItem:: ...:
TileView.cpp.obj
This is for sure not MinGW. You can not mix MingW and MSVC libraries. Make sure you use the compiler for which you've installed Qt (msvc or mingw, you still not answered this).
-
-
@Karlos said in CMake Undefined Reference to `QGraphicsItem:: ...:
and then installed MinGW 8.1.0 from the mingw-w64 site
You should prefer MinGW provided by Qt installer instead.
-