Cannot compile any Qt project on Windows due to a missing stddef.h include
-
Hi!
This morning I started to have exactly the same problem. In my case I'm using Windows 11, the latest version of Qt Creator and QT 5.15.2 for Visual Studio 2022.
Could you solve the problem?
At this very moment I'm reinstalling Qt, to see if this works.
Bleriot.
-
@bleriot13
Could you please star by Googling:Cannot open include file: 'stddef.h': No such file or directory
because there are so many hits over the years for this. The OP was Windows 10, you will notice how many people say that (re-)installing the Windows SDK fixes. Maybe you need to do same for Windows 11, I don't know? in any case have a read through the reports/solutions.
-
@bleriot13 said in Cannot compile any Qt project on Windows due to a missing stddef.h include:
I guess that this will also reinstall the Windows SDK...
I do not know whether MSVC includes this or you just fetch it standalone, like the others appear to have done.
P.S.
I am sorry, I only just noticed that you did list a number of threads from this forum related tostddef
which you had indeed read. From a Google just check whether any other posts elsewhere than this forum are of any help. -
@bleriot13 said in Cannot compile any Qt project on Windows due to a missing stddef.h include:
I guess that this will also reinstall the Windows SDK
No, it will not. You have to do that on your own.
-
@jsulm Reinstalling the Windows SKD DID NOT SOLVE the problem.
I wonder if I installed the RIGHT version... The installer I downloaded simply asked to go on and on and then offered a series of checkboxes that I left marked (so everything in the SDK has been installed).
I have noticed that I already had version 10.0.22000.0 and that now the installer added version 10.0.22621.0. I think that if the SDK is the problem, then I don't have the version QT expects to find.
How can I discover what SDK version is Qt expecting?
Thanks!
-
@bleriot13
Have you looked at, say, https://stackoverflow.com/questions/62024970/why-cant-qt-creator-find-the-windows-10-sdk-headers ? There it is suggested:set VSCMD_DEBUG=3 vcvars64.bat > log.txt
And/or the last post there claims to work for what it shows for setting
INCLUDEPATH
/LIBS
.Also the paths you use have
10.0.19041.0
in them How does that relate to the10.0.22000.0
or10.0.22621.0
you now mention? -
I have run vcvars64.bat and I have no problems in the log. Apparently, at least, the registry problems reported by that thread do not happen in my case.
What it's true is that if I open a cmd window (from the MSVC menu) for x64 development and I type SET, the paths to the Windows SDK do not appear neither in the INCLUDEPATH nor in LIB, so, clearly, this is the cause of the problem. Why they do not appear there is the problem to solve, I guess.
The solution of the last post in the stackoverflow thread may work, of course, but it's a rather dirty solution. This means modifying all my project files (I have a rather big bunch of these) and, furthermore, whenever the SDK is updated I have to change the .pro files again...
Concerning the versions reported in the first post of this thread... these are the ones related to the SDK used by the user that first had this problem, not me!!!
I have identified the precise version of the SDK that I have been using at least since January this year (found it in the list of installed apps). Then, I have downloaded the installer of the SDK for this precise version, removed the one in my computer, and reinstalled it once more. I have restarted the system and the problem is still there...
Tomorrow I will uninstall - reinstall everything, hoping for the best.
I have to say that this is the SECOND time this happens to me. A year ago, more or less, it happened by the first time... And the only solution to solve the issue was reinstall windows completely. At least, with the solution in the last post of the stackoverflow thread, I hope, I 'll be able to avoid rebuilding my computer...
-
@bleriot13
Point taken about you not being the OP!"Reinstalling Windows" all sounds a bit drastic! What about tracking down where the
Cannot open include file: 'stddef.h': No such file or directory
emanates from?I don't use Windows or MSVC. But I think it does include paths explicitly on the command line to the
cl.exe
rather than in environment variables? Or, thevcvars
shows what is relevant environment variables? You must be able to ask MSVC/VS to show you the full command line being issued for each compilation? So I would get that, maybe get environment variable values too, look insideMSVC\14.29.30133\include\cstddef(12)
at line #12, see where I have any file namedstddef.h
anywhere on the PC, and take it from there? -
@JonB Hi!
By "reinstalling everything" I meant VS 2022 and Qt, not the whole Windows OS.
I have tried the solution in the last post of the stackoverflow thread, adding the following lines to my .pro file:
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.22000.0/cppwinrt/winrt"
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.22000.0/shared"
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.22000.0/ucrt"
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.22000.0/um"
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.22000.0/winrt"LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22000.0/ucrt/x64"
LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22000.0/ucrt_enclave/x64"
LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22000.0/um/x64"And the original problems related to the inclusion of stddef.h have gone away. However, now the problems are other.
First: I have a resources file (to include just one image in my app). Well, jom complains about the existence of a .res file that, supposedly, should have been generated somehow.
Second: if I remove the resource file to see what happens, then the problem change and I get this:
LINK : fatal error LNK1158: cannot run 'rc.exe'
Assuming that QtCreator was not able to find rc.exe, I added the following line to my .pro file:
QMAKE_RC = "C:/Program Files (x86)/Windows Kits/10/bin/10.0.22000.0/x64/rc.exe"
which is part of the Windows SDK. However, the problem persists.
So my conclusion is that, by whatever reason, the Windows SDK is not correctly installed and not only the include / library directories are not available, but also other parts required to perform the building.
As I said yesterday, I'm going to uninstall everything, Window SDK, MSVC 2022 and Qt 5.12.2.
I'm not confident at all that this will work. I already did that in the past and it didn't worked, so I had to reinstall Windows completely. However, I must give it a try.