TajniakOsz TajniakOsz - 2 months ago 141
C++ Question

Qt Creator C1083: Cannot open include file: 'cstddef': No such file or directory

I try to build a programm in Qt Creator (Qt5.7.0) on Windows 10 but I get


D:\Qt\Qt5.7.0\5.7\msvc2015_64\include\QtCore\qglobal.h:45: error: C1083: Cannot open include file: 'cstddef': No such file or directory


error message. I found out that it may be caused by lack of Windows SDK but I installed it, ran
vcvarsall.bat
and nothing happened. I try to use "MinGW 5.3.0 32-bit" compiler and "GNU gdb 7.10.1 for MinGW 5.3.0 32-bit" debugger (using "Microsoft Visual C++ Compiler" doesn't work as well). Any ideas?

Answer

First of all, when you compile your project under Qt Creator, you're using a particular kit, tied to a particular installed Qt version. Make sure that the configuration of that kit and that Qt version in Qt Creator has the right compiler selected. C++ code is generally not binary compatible across compilers, so if you've installed a Qt version for say MSVC2012, it'll only work with that compiler and no other. If you're not building Qt yourself, the Qt version you installed must match the compiler you're using it with. Mixing MSVC versions or using a MSVC-built Qt with mingw gcc won't work.

You can have multiple installations of Qt side by side, and each installation can use a different Qt version and/or compiler. You need to let Qt Creator know about them by adding them to the Qt Versions control pane, and then setting up the kits that use these Qt versions.

There's no point to running vcvars yourself, since it only sets the environment variables for that particular instance of the command processor. It has no effect on Qt Creator. Qt Creator's build system automatically invokes vcvars to set up an environment that the build is executed in.