I am trying to build a C++ project on VS. The project was developed using NetBeans in a Linux machine and now I am using Visual Studio 2017 on Windows.
It wasn't developed using Qt Creatos so the libraries has been added manually with sentences like:
#include <QtCore>
#include <QCoreApplication>
#include <QObject>
#include <QStringList>
#include <QMap>
...
This is what I did so far:
- Downloaded the last Qt release
- Unpacked everything in C:\Qt
- In VS properties > VC++ Directories > Include directories - I added C:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include and C:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore
- In VS properties > VC++ Directories > Library directories - I added C:\Qt\Qt5.9.2\5.9.2\msvc2017_64\lib
However, when I try to #include <QtCore>
it seems like VS expects something more:
https://imgur.com/a/ruSbi
but it doesn't compile.
Severity Code Description Project File Line Suppression State
Error (active) E0020 identifier "QEvent" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qabstractanimation.h 121
Error (active) E0020 identifier "QEvent" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qabstractstate.h 73
Error (active) E0020 identifier "QEvent" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qabstractstate.h 74
Error (active) E0020 identifier "QEvent" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qabstractstate.h 76
Error (active) E1455 member function declared with 'override' does not override a base class member c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qabstracttransition.h 105
Error (active) E1455 member function declared with 'override' does not override a base class member c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qanimationgroup.h 70
Error (active) E1455 member function declared with 'override' does not override a base class member c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qcoreapplication.h 190
Error (active) E0020 identifier "qint8" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qdatastream.h 147
Error (active) E0020 identifier "qint8" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qdatastream.h 163
Error (active) E0260 explicit type is missing ('int' assumed) c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qendian.h 236
Error (active) E0801 "qint8" is not a class or function template name in the current scope c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qendian.h 236
Error (active) E0065 expected a ';' c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qendian.h 236
Error (active) E0020 identifier "qint8" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qendian.h 236
Error (active) E0020 identifier "QEvent" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qeventloop.h 79
Error (active) E1455 member function declared with 'override' does not override a base class member
...
So, I guess I'm missing something. I am new with VS, so I would appreciate any help.
Thank you
QtCore
is both a directory and an include file:Also you need to run the Qt
moc
on every header that contains theQ_OBJECT
macro. Themoc
will generate extra C++ files, which you need to compile. It is fairly straightforward when using tools likeqmake
orcmake
. For VS you might wan to use Qt Visual Studio Add-in.