IL2CPP Failing in Windows Machine

Hi there,

I have recently downgraded Visual Studio from 2019 back to 2017 which I was using for a long time with no issues. Now when I'm compiling for Windows x86-64 with IL2CPP .Net x4 I'm getting the following error:

[quote]
Failed running D:\Program Files Overflow\Unity Installs\2019.3.13f1\Editor\Data\il2cpp/build/deploy/net471/il2cpp.exe --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="WindowsDesktop" --architecture="x64" --configuration="Release" --outputpath="D:\Git\SketchWork\Broke Text Mesh Pro\Broke Text Mesh Pro\Temp/StagingArea/Data\Native\GameAssembly.dll" --cachedirectory="D:\Git\SketchWork\Broke Text Mesh Pro\Broke Text Mesh Pro\Assets..\Library/il2cpp_cache" --profiler-report --map-file-parser="D:/Program Files Overflow/Unity Installs/2019.3.13f1/Editor/Data/Tools/MapFileParser/MapFileParser.exe" --directory="D:/Git/SketchWork/Broke Text Mesh Pro/Broke Text Mesh Pro/Temp/StagingArea/Data/Managed" --generatedcppdir="D:/Git/SketchWork/Broke Text Mesh Pro/Broke Text Mesh Pro/Temp/StagingArea/Data/il2cppOutput"

stdout:
Building GameAssembly.dll with MsvcDesktopToolChain
Msvc Install Version: 15.0
Msvc Install SDK Directory: C:\Program Files (x86)\Windows Kits\10
Msvc Linker Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.exe
Msvc Compiler Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.exe

Output directory: D:\Git\SketchWork\Broke Text Mesh Pro\Broke Text Mesh Pro\Temp\StagingArea\Data\Native
Cache directory: D:\Git\SketchWork\Broke Text Mesh Pro\Broke Text Mesh Pro\Library\il2cpp_cache
il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: Il2CppTypeDefinitions.c
D:\Program Files Overflow\Unity Installs\2019.3.13f1\Editor\Data\il2cpp\libil2cpp\il2cpp-config.h(3): fatal error C1083: Cannot open include file: 'assert.h': No such file or directory

Invocation was: Executable: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.exe"
Arguments: "D:\Git\SketchWork\Broke Text Mesh Pro\Broke Text Mesh Pro\Temp\StagingArea\Data\il2cppOutput\Il2CppTypeDefinitions.c" /nologo /c /bigobj /W3 /Zi /EHs /GR- /Gy /utf-8 /wd4102 /wd4800 /wd4056 /wd4190 /wd4723 /wd4467 /wd4503 /wd4996 /wd4200 /Ox /Oi /Oy- /GS- /Gw /GF /Zo /MT /DNET_4_0 /DUNITY_AOT /DIL2CPP_MONO_DEBUGGER_DISABLED /DGC_NOT_DLL /DRUNTIME_IL2CPP /D_WIN32 /DWIN32 /DWIN32_THREADS /D_WINDOWS /DWINDOWS /D_UNICODE /DUNICODE /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /D_WINSOCK_DEPRECATED_NO_WARNINGS /DNOMINMAX /D_NDEBUG /DNDEBUG /DWINDOWS_SDK_BUILD_VERSION=19041 /DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP /I"D:\Program Files Overflow\Unity Installs\2019.3.13f1\Editor\Data\il2cpp\libil2cpp" /I"D:\Program Files Overflow\Unity Installs\2019.3.13f1\Editor\Data\il2cpp\libil2cpp" /I"D:\Program Files Overflow\Unity Installs\2019.3.13f1\Editor\Data\il2cpp\external\bdwgc\include" /I"D:\Program Files Overflow\Unity Installs\2019.3.13f1\Editor\Data\il2cpp\external\xxHash" /I"D:\Git\SketchWork\Broke Text Mesh Pro\Broke Text Mesh Pro\Temp\StagingArea\Data\il2cppOutput" /I"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\winrt" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt" /Fo"D:\Git\SketchWork\Broke Text Mesh Pro\Broke Text Mesh Pro\Library\il2cpp_cache\C11B3435AA4C20A2C2A2468BF55FC51F.obj" /Fd"D:\Git\SketchWork\Broke Text Mesh Pro\Broke Text Mesh Pro\Library\il2cpp_cache\C11B3435AA4C20A2C2A2468BF55FC51F.pdb"
EnvArg key: PATH value: C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Windows Kits\10\bin\x86;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64

at Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable1 sourceFilesToCompile, IBuildStatisticsCollector statisticsCollector)
at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
at il2cpp.Program.DoRun(String[ ] args, List
1 foundAssemblies)
at il2cpp.Program.Run(String[ ] args, Boolean setInvariantCulture)
at il2cpp.Program.Main(String[ ] args)
stderr:

Unhandled Exception: Unity.IL2CPP.Building.BuilderFailedException: Il2CppTypeDefinitions.c
D:\Program Files Overflow\Unity Installs\2019.3.13f1\Editor\Data\il2cpp\libil2cpp\il2cpp-config.h(3): fatal error C1083: Cannot open include file: 'assert.h': No such file or directory

Invocation was: Executable: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\cl.exe"
Arguments: "D:\Git\SketchWork\Broke Text Mesh Pro\Broke Text Mesh Pro\Temp\StagingArea\Data\il2cppOutput\Il2CppTypeDefinitions.c" /nologo /c /bigobj /W3 /Zi /EHs /GR- /Gy /utf-8 /wd4102 /wd4800 /wd4056 /wd4190 /wd4723 /wd4467 /wd4503 /wd4996 /wd4200 /Ox /Oi /Oy- /GS- /Gw /GF /Zo /MT /DNET_4_0 /DUNITY_AOT /DIL2CPP_MONO_DEBUGGER_DISABLED /DGC_NOT_DLL /DRUNTIME_IL2CPP /D_WIN32 /DWIN32 /DWIN32_THREADS /D_WINDOWS /DWINDOWS /D_UNICODE /DUNICODE /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /D_WINSOCK_DEPRECATED_NO_WARNINGS /DNOMINMAX /D_NDEBUG /DNDEBUG /DWINDOWS_SDK_BUILD_VERSION=19041 /DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP /I"D:\Program Files Overflow\Unity Installs\2019.3.13f1\Editor\Data\il2cpp\libil2cpp" /I"D:\Program Files Overflow\Unity Installs\2019.3.13f1\Editor\Data\il2cpp\libil2cpp" /I"D:\Program Files Overflow\Unity Installs\2019.3.13f1\Editor\Data\il2cpp\external\bdwgc\include" /I"D:\Program Files Overflow\Unity Installs\2019.3.13f1\Editor\Data\il2cpp\external\xxHash" /I"D:\Git\SketchWork\Broke Text Mesh Pro\Broke Text Mesh Pro\Temp\StagingArea\Data\il2cppOutput" /I"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\winrt" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt" /Fo"D:\Git\SketchWork\Broke Text Mesh Pro\Broke Text Mesh Pro\Library\il2cpp_cache\C11B3435AA4C20A2C2A2468BF55FC51F.obj" /Fd"D:\Git\SketchWork\Broke Text Mesh Pro\Broke Text Mesh Pro\Library\il2cpp_cache\C11B3435AA4C20A2C2A2468BF55FC51F.pdb"
EnvArg key: PATH value: C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Windows Kits\10\bin\x86;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64

at Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable1 sourceFilesToCompile, IBuildStatisticsCollector statisticsCollector)
at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
at il2cpp.Program.DoRun(String[ ] args, List
1 foundAssemblies)
at il2cpp.Program.Run(String[ ] args, Boolean setInvariantCulture)
at il2cpp.Program.Main(String[ ] args)

UnityEngine.Debug:LogError(Object)
UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase)
UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action1)
UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List
1, Action1, String)
UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(Il2CppBuildPipelineData, String, String, Boolean)
UnityEditorInternal.IL2CPPBuilder:Run()
UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, IIl2CppPlatformProvider, Action
1, RuntimeClassRegistry)
DesktopStandalonePostProcessor:SetupStagingArea(BuildPostProcessArgs, HashSet`1)
DesktopStandalonePostProcessor:postProcess(BuildPostProcessArgs)
UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
[/quote]

One thing I noticed is that unity is still trying to use Windows Kit 10.0.19041.0 which was a part of the VS2019 install and is no longer there. Where is it getting this old version of WinSDK from even if that is the problem at all.

Help please :(

Justin

1 Like

Likely when you uninstalled Visual Studio, it didn't cleanup the registry and it's still saying that SDK is installed. You can either install that SDK back (you can use it with VS2017) from https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/, or you can manually change the registry values to point to older SDK at "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v10.0".

6 Likes

Hey @Tautvydas-Zilys ,

You my friend are awesome. This fixed my issue and I'm able to continue building again. One thing to make a note of is that the new Win 10 SDK 10.0.19041.0 released on the 15th May 2020 has some issues with sockets in Unity. All my networking broke, reverting back to Win 10 SDK 10.0.17763.0 and all networking works again.

This new version is now installed automatically with VS2019 in case others get issues.

Justin

2 Likes

I had a similar problem caused by the latest Windows 10 SDK 10.0.19041.0 which is not fully compatible with unity il2cpp yet.
(async TcpClient socket connect causes an "ArgumentException: Value does not fall within the expected range." while using it at least with NoDelay and specific timeout values.)
This is a general problem I have encountered before. I had the exact same problem some time ago with 10.0.18362.0 when it was first available.
Unity probably should have a way to select the Windows 10 SDK to use for il2cpp builds if multiple versions are available instead of always using the latest one.
The other issue that, even after uninstalling the newest Windows 10 SDK the above-mentioned registry key isn't properly updated, technically is the fault of Microsoft but finger-pointing doesn't really help anyone.
Being able to ourselves select the Windows SDK to use is all we would need to get around these kinds of obscure issues which can be incredibly frustrating to debug.

1 Like

Can you report a bug on this?

tracker id: 1249143
Please tell me if you didn't mean that.

1 Like

This was exactly the same error I was having which is what led to us rolling back to a previous Win 10 SDK version.

Justin

1 Like

I had this issue too. 9xxx SDK breaks IL2CPP sockets. https://discussions.unity.com/t/794272

UWP build has a drowdown for selecting SDK versjon. Seems like an error that desktop windows does not.

We have a fix for this coming, all the way back to Unity 2018.4. If you want to work around sooner, here's the source code patch (you can find it at Editor\Data\il2cpp):

diff --git a/libil2cpp/os/Win32/SocketImpl.cpp b/libil2cpp/os/Win32/SocketImpl.cpp
index f63abecd5..5821d2577 100644
--- a/libil2cpp/os/Win32/SocketImpl.cpp
+++ b/libil2cpp/os/Win32/SocketImpl.cpp
@@ -1700,11 +1700,7 @@ namespace os
                 break;

             case kSocketOptionLevelIP:
-#ifdef SOL_IP
-                *system_level = SOL_IP;
-#else
                 *system_level = IPPROTO_IP;
-#endif

                 switch (name)
                 {
@@ -1777,11 +1773,7 @@ namespace os
                 break;
 #if IL2CPP_SUPPORT_IPV6
             case kSocketOptionLevelIPv6:
-        #ifdef SOL_IPV6
-                *system_level = SOL_IPV6;
-        #else
                 *system_level = IPPROTO_IPV6;
-        #endif

                 switch (name)
                 {
2 Likes

Is there an ETA on when this patch will come out? Will it be pushed to Unity 2019.x?

Yeah it going to both 2019.4 and 2018.4. The backport is on the way but I don't have any concrete dates to share.

1 Like


Thank you for the response, does this mean it's live in 2019.4 currently?

No, it's not. It will be in a future 2019.4.x release.

1 Like


Is it in 2019.4.3f1?


I have just upgraded to 2019.4.3f1 because I ran into the above problem when building for HoloLens 2. Unfortunately the fix seems not to be included in this version yet.

However, I was able to manually patch the file "Win32/SocketImpl.cpp" by removing the SOL_IP references and got it working!

@BenjaminBachman

I'm running into the same issue, what did you change here to make this happen? can you post your code?

Go to "Installs", click on the 3 dots:
6090762--661542--upload_2020-7-14_23-24-5.png

Select "Show in Explorer":

6090762--661545--upload_2020-7-14_23-24-32.png

You should arrive in something like "C:\Program Files\Unity\Hub\Editor\2019.4.3f1\Editor"
Go to the sub-folder "...\Data\il2cpp\libil2cpp\os\Win32" and open the file "SocketImpl.cpp" in an editor of your choice.

then go to around line 1700 and delete the lines reading

  • #ifdef SOL_IP
  • *system_level = SOL_IP;
  • #else
  • #endif

The line reading "*system_level = IPPROTO_IP;" should remain.
Go to line 1777 and do the same there.

Restart Unity, rebuild your project. Maybe you have to delete the build folder first.

when I try this i get the following error
6097971--662835--upload_2020-7-16_11-29-6.png

Guess i'll have to wait for the official fix.

That is not a crash. Uncheck "Break when this exception type is thrown" and it will go away.

Just tested this in 2020.1.0f1 and it seems it has still not been fixed yet.