I have read the question Can I use Qt without qmake or Qt Creator? which is basically the same for Linux, and very useful.
How to compile a basic program using QtCore (console application, even without GUI) on Windows, without using qmake
or qtCreator IDE, but just the Microsoft VC++ compiler cl.exe
?
For example, let's say we have:
#include <iostream>
#include <QtCore>
int main()
{
QVector<int> a; // Qt object
for (int i=0; i<10; i++)
a.append(i);
std::cout << "hello";
return 0;
}
Using:
call "C:\path\to\vcvarsall.bat" x64
cl main.cpp /I D:\coding\qt\qtbase-everywhere-src-5.15.5\include
fails with:
D:\coding\qt\qtbase-everywhere-src-5.15.5\include\QtCore\QtCore(3): fatal error C1083: Cannot open include file: 'QtCore/QtCoreDepends': No such file or directory
Indeed this file is not present in the release qtbase-everywhere-opensource-src-5.15.5.zip from https://download.qt.io/archive/qt/5.15/5.15.4/submodules/.
TL;DR: More generally, which cl.exe
arguments should we use to to able to use all Qt includes, and effectively compile such a minimal project using QtCore?
cl.exe
includes and lib parameters to avoid to include every single subdirectory of qt as/I
parameters manually. Is there a single include directive that would automatically work (with relative paths for example)? – Sturrockqtbase-everywhere-opensource-src-5.15.4.zip
seem to contain them in theinclude
subfolder, so I guess yes. – Sturrock