Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

IL2CPP unable to build with VS 2019?

Discussion in '2019.3 Beta' started by God-at-play, Dec 27, 2019.

  1. God-at-play

    God-at-play

    Joined:
    Nov 3, 2006
    Posts:
    330
    I'm trying to make a Windows build using IL2CPP from 2019.3.0f3, which was installed via Unity Hub. But I get an error while building, it seems IL2CPP wants VS 2015 or 2017? Either that or Hub should have set up VS to install Windows 10 SDK and it didn't?

    Code (CSharp):
    1. Failed running C:\Program Files\Unity\Hub\Editor\2019.3.0f3\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="x86" --configuration="Release" --outputpath="G:\agilelens\Temp/StagingArea/Data\Native\GameAssembly.dll" --cachedirectory="G:\agilelens\Assets\..\Library/il2cpp_cache" --profiler-report --map-file-parser="C:/Program Files/Unity/Hub/Editor/2019.3.0f3/Editor/Data/Tools/MapFileParser/MapFileParser.exe" --directory=G:/agilelens/Temp/StagingArea/Data/Managed --generatedcppdir=G:/agilelens/Temp/StagingArea/Data/il2cppOutput
    2.  
    3. stdout:
    4. il2cpp.exe didn't catch exception: System.InvalidOperationException: C++ code builder is unable to build C++ code. In order to build C++ code for Windows Desktop, you must have one of these installed:
    5.        Visual Studio 2015 with C++ compilers and Windows 10 SDK (it cannot build C++ code because it is not installed)
    6.        Visual Studio 2015 installation is found by looking at "SOFTWARE\Microsoft\VisualStudio\14.0_Config\InstallDir" in the registry
    7.        Windows 10 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0\InstallationFolder" in the registry
    8.  
    9.        Visual Studio 2017 with C++ compilers and Windows 10 SDK (it cannot build C++ code because Windows SDK is not installed)
    10.        Visual Studio 2017 installation is found using Microsoft.VisualStudio.Setup.Configuration COM APIs
    11.        Windows 10 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0\InstallationFolder" in the registry
    12.  
    13.  
    14.   at Unity.IL2CPP.Building.CppProgramBuilder.ThrowIfCannotBuildInCurrentEnvironment()
    15.   at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    16.   at il2cpp.Program.DoRun(String[] args, List`1 foundAssemblies)
    17.   at il2cpp.Program.Run(String[] args, Boolean setInvariantCulture)
    18.   at il2cpp.Program.Main(String[] args)
    19. stderr:
    20.  
    21. Unhandled Exception: System.InvalidOperationException: C++ code builder is unable to build C++ code. In order to build C++ code for Windows Desktop, you must have one of these installed:
    22.        Visual Studio 2015 with C++ compilers and Windows 10 SDK (it cannot build C++ code because it is not installed)
    23.        Visual Studio 2015 installation is found by looking at "SOFTWARE\Microsoft\VisualStudio\14.0_Config\InstallDir" in the registry
    24.        Windows 10 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0\InstallationFolder" in the registry
    25.  
    26.        Visual Studio 2017 with C++ compilers and Windows 10 SDK (it cannot build C++ code because Windows SDK is not installed)
    27.        Visual Studio 2017 installation is found using Microsoft.VisualStudio.Setup.Configuration COM APIs
    28.        Windows 10 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0\InstallationFolder" in the registry
    29.  
    30.  
    31.   at Unity.IL2CPP.Building.CppProgramBuilder.ThrowIfCannotBuildInCurrentEnvironment()
    32.   at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
    33.   at il2cpp.Program.DoRun(String[] args, List`1 foundAssemblies)
    34.   at il2cpp.Program.Run(String[] args, Boolean setInvariantCulture)
    35.   at il2cpp.Program.Main(String[] args)
    36.  
    37. UnityEngine.Debug:LogError(Object)
    38. UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase)
    39. UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action`1)
    40. UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List`1, Action`1, String)
    41. UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(Il2CppBuildPipelineData, String, String, Boolean)
    42. UnityEditorInternal.IL2CPPBuilder:Run()
    43. UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry)
    44. DesktopStandalonePostProcessor:SetupStagingArea(BuildPostProcessArgs, HashSet`1)
    45. DesktopStandalonePostProcessor:PostProcess(BuildPostProcessArgs)
    46. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
  3. God-at-play

    God-at-play

    Joined:
    Nov 3, 2006
    Posts:
    330
    Maybe my issue is that I didn't install Visual Studio again from my newer 2019.3 install? I already installed VS 2019 from a previous editor install. Then I installed 2019.3.0f3 but left VS unchecked because it was already installed. Maybe that is it? It'd be nice if Unity Hub handled this better.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    No, that should have worked. All Unity versions install the same thing. Do IL2CPP builds actually succeed in the previous editor install?

    Are you able to create a C++ application from installed Visual Studio?
     
  5. God-at-play

    God-at-play

    Joined:
    Nov 3, 2006
    Posts:
    330
    I'd never tried an IL2CPP until then (on this new computer, I've done it before of course). I'm not sure how Win 10 SDK didn't get installed the first time around, but I went into the VS menu for installed add-ons and saw the SDK was unchecked, so I installed it manually and that fixed it.

    Although now that I think of it, when I went to finish building with IL2CPP, I had problems with a plugin not loading. Deleting the build, deleting the cache in Library, dropping back to Mono, none of that worked. Even after deleting my whole Library folder and letting everything reimport, that didn't help. I had to start my project over from scratch and bring in the project folders piece-by-piece. I left it Mono and the build finally worked. Not sure if that's related, but it was weird for sure.
     
  6. KCAR

    KCAR

    Joined:
    Oct 20, 2013
    Posts:
    9
  7. pmerilainen

    pmerilainen

    Joined:
    Dec 23, 2013
    Posts:
    7
    I had the exact same problem - IL2CPP was not compiling Windows Desktop builds with VS 2019 Professional (Unity 2019.4).

    I did have to install the Windows 10 SDK from the link provided by replies in this thread.
    +plus I also had to install the "Desktop Development with C++" add-on to the Visual Studio itself.

    The easiest way to add the C++ Development is to use the internal search bar within the Visual Studio - just type "Desktop Development with C++" and open the installer package.
    The installer will then download and add the C++ component - after installing it I was able to compile Windows Desktop builds with IL2CPP; I didn't even have to re-start either VS or Unity.
     
    Demexis, Ahab_, Volchok and 10 others like this.
  8. dCalle

    dCalle

    Joined:
    Dec 16, 2013
    Posts:
    55
    yeah it would be kinda nice to get this notice before they game tries to build... and provide the required components as a module ( windows 10 sdk and c++)
     
  9. melkior

    melkior

    Joined:
    Jul 20, 2013
    Posts:
    199
    I had a SATA disk controller die so had to reinstall my system and ran into this.

    As a note I do not use Visual Studio - I use Jetbrains Rider.

    My steps:

    - I installed Unity 2019 LTS via hub
    - downloaded my project from git
    - tried to build a desktop windows build
    - got the error
    - used the hub to install VS 2019 assuming it would resolve issue
    - still have the error
    - download && install Windows 10 SDK
    - issue resolved

    So from my fresh install recently it would appear that the installer does not resolve all dependencies properly in the case of VS 2019.
     
  10. AndreiMarian

    AndreiMarian

    Joined:
    Jun 9, 2015
    Posts:
    77
    From Windows 10 SDK only platform specific features need to be installed:

     
    MilenaRocha, LARP, Pjotrh96 and 10 others like this.
  11. AhmenX

    AhmenX

    Joined:
    Mar 22, 2016
    Posts:
    7
    Same problem here. These steps fixed it.
    You may need to reboot your computer for these to take effect.
     
  12. adamstepinski

    adamstepinski

    Joined:
    Aug 7, 2015
    Posts:
    57
    For me uninstalling Visual Studio and adding it again via "Add Modules" from Unity HUB > Installs solved the problem