mstorsjo / msvc-wine

Scripts for setting up and running MSVC in Wine on Linux
Other
669 stars 82 forks source link

fatal error C1083: Cannot open include file: 'windows.h': No such file or directory #139

Open hacksysteam opened 1 month ago

hacksysteam commented 1 month ago

When using the latest WDK, there are 2 (10.x) directories. The fixincludes or lowercase script does not create appropriate changes.

- WDK_INSTALLER_URL: "https://go.microsoft.com/fwlink/?linkid=2249371"
+ WDK_INSTALLER_URL: "https://go.microsoft.com/fwlink/?linkid=2272234"
#13 37.04 Merging WDK 'Build' and 'build' directories into version 10.0.26100.0
#13 37.04 Moving WDK.Legacy.props into version 10.0.26100.0
#13 37.04 Moving WDK.props into version 10.0.26100.0
#13 37.60 Using SDK version 10.0.26100.0
#13 38.46 Using MSVC version 14.41.34120
#13 42.17 Build msvctricks ...
#13 42.25 Microsoft (R) C/C++ Optimizing Compiler Version 19.41.34120 for x64
#13 42.25 Copyright (C) Microsoft Corporation.  All rights reserved.
#13 42.25 
#13 42.25 msvctricks.cpp
#13 42.25 z:/tmp/msvc-wine/msvctricks.cpp(17): fatal error C1083: Cannot open include file: 'windows.h': No such file or directory

Failing action: https://github.com/hacksysteam/msvc-wine/actions/runs/10872722342/job/30168067508 Diff: https://github.com/hacksysteam/msvc-wine/commit/9978f9c972d1cbc0bfab58781292f28f524d557f?diff=split&w=0

huangqinjin commented 1 month ago

The latest WDK requires Windows SDK 10.0.26100, you may try add --sdk-version 10.0.26100.

hacksysteam commented 1 month ago

But windows.h is not there in this version and the issue only happens when we install wdk, without wdk it works

huangqinjin commented 1 month ago

By default, Windows SDK 10.0.22621 is installed. If you install WDK also, directory 10.0.26100.0 is also created but only contains WDK not SDK. And wrappers always choose the maximum version.

hacksysteam commented 1 month ago

Yes, that's the issue. Any idea how to fix it?

huangqinjin commented 1 month ago

WDK and SDK version must match, so --sdk-version should be used. A better solution IMO is to use nupkg (https://github.com/mstorsjo/msvc-wine/issues/113#issuecomment-2198478443), so that we can specify the WDK version to download .

hacksysteam commented 1 month ago

Ah! Makes sense now. But one more thing, even if I use the older wdk link which is there in the workflow file, I still get the same issue. But it works on Ubuntu image on github actions. I'm using a Debian container and get same missing Windows.h something weird is happening

hacksysteam commented 1 month ago

Hi @huangqinjin after merging your pull request, the issue persists.

#14 32.99 Unpacking WDK VS extension WDK.vsix
#14 33.02 Merging WDK 'Build' and 'build' directories into version 10.0.22621.0
#14 33.02 Moving WDK.Legacy.props into version 10.0.22621.0
#14 33.02 Moving WDK.props into version 10.0.22621.0
#14 33.64 Using SDK version 10.0.22621.0
#14 34.48 Using MSVC version 14.41.34120
#14 38.65 Build msvctricks ...
#14 38.74 msvctricks.cpp
#14 38.74 z:/tmp/msvc-wine/msvctricks.cpp(17): fatal error C1083: Cannot open include file: 'windows.h': No such file or directory

this time it could select the correct SDK version as I specified in the command line.

python3 vsdownload.py --accept-license \
        --dest ${MSVC_HOME} \
        --host-arch x64 \
        --architecture x86 x64 \
        --sdk-version 10.0.22621.0 \
        --cache /tmp/msvc \
        --with-wdk-installers /tmp/wdk/Installers; \
bash install.sh ${MSVC_HOME};
hacksysteam commented 1 month ago

So instead of specifying the --sdk-version if we specify the --msvc-version then it works with and without wdk.

Updated command:

python3 vsdownload.py --accept-license \
        --dest ${MSVC_HOME} \
        --host-arch x64 \
        --architecture x86 x64 \
        --msvc-version 17.11 \
        --cache /tmp/msvc \
        --with-wdk-installers /tmp/wdk/Installers; \
bash install.sh ${MSVC_HOME};
hacksysteam commented 1 month ago

New issue, there is no msbuild.exe in the MSVC_HOME directory

hacksysteam commented 1 month ago

Update: the issue is resolved, seems there was an issue with the downloaded files.

WDK_INSTALLER_URL="https://go.microsoft.com/fwlink/?linkid=2249371"
python3 ./vsdownload.py --accept-license \
        --dest ${MSVC_HOME} \
        --host-arch x64 \
        --architecture x86 x64 \
        --with-wdk-installers /tmp/wdk/Installers;

All tests passed as well.