Cannot compile any Qt project on Windows due to a missing stddef.h include
-
@JonB Thanks for your comments.
Unfortunately, reinstalling Qt didn't work. Now I'll try to reinstall both MSVC (first) and Qt (later on). I guess that this will also reinstall the Windows SDK...
Bleriot.
@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. -
@JonB Thanks for your comments.
Unfortunately, reinstalling Qt didn't work. Now I'll try to reinstall both MSVC (first) and Qt (later on). I guess that this will also reinstall the Windows SDK...
Bleriot.
@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.
-
@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!
-
@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? -
@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...
-
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? -
@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.
-
Coming back to this after a year since originally posted.
While I don't have a solution different than what was described in the first entry, I have encountered this issue again.
This time I am on a clean Windows 11 OS, a newer version of Qt, still using MSVC with BuildTools 2019 and the problem has started ever since I chose to update the BuildTools. I was prompted there is an update available, I let it do its thing and I have the same problem.
I have used the documented workaround and I am ok with that, but for those who come across this thread - be careful when updating your BuildTools - it might trigger such issue for you too.
-
Sorry for not posting before, but I had completely forgotten about this thread!!!
The problem is not happening lately; now I'm using Qt Creator 17.0.0 and the latest (as of today) version of MSVC 2022. However, the last times this problem happened I could solved more or less quickly following the steps below:
Go to folder %appdata%\roaming. Here, delete subfolder QtProject
Still in %appdata%\roaming... I'm not sure about whether deleting subfolder Qt is necessary, since it contains your credentials to log into the Qt websites. Normally, I delete it and when finishing the process I retype the credentials once more.
Then go to folder %appdata%\local. Then delete subfolder QtProject.
Then go to folder %appdata%\Temp and there delete all files whose name start with "QtCreator-" (there will be quite a few!)
Finally, using the Qt Maintenance Tool, uninstall Qt Creator. Once that it's been completely uninstalled, reinstall it again.
As I said, this worked for me the last two or three times the problem arised. Can't guarantee that it'll work for everybody!
I guess that deleting the files and folder listed above I'm cleaning all traces pointing to MSVC. Uninstalling and reinstalling forces re-creating (hopefully) correctly these links.