Yearly IL2CPP on Standalone Thread

Sorry to pull this off topic but i have a question about Il2CPP standalone.

Will it still be possible to load a (c#) assembly at runtime (for example to load a plugin or ‘mod’) if the game was built with IL2CPP?

How does that work?

Dynamic loading of code when application was built with IL2CPP will not be possible. We are considering how/if to enable this, but it’s not possible for the foreseeable future

I assume this also applies for the CSharpCodeProvider Class https://msdn.microsoft.com/en-us/en-en/library/microsoft.csharp.csharpcodeprovider(v=vs.110).aspx
which would allow to compile/create the code in memory?

Is there a list which (C#) features are not available with IL2CPP (or general things which should be avoided/noted)?

See this page: https://docs.unity3d.com/Manual/ScriptingRestrictions.html

1 Like

Thanks for the link! Looks like the System.Xml.Serialization.XmlSerializer will also be a no-go, because it uses reflection and creates a dynamic assembly behind the scenes.

I currently can’t play around with it, because im working on a windows standalone project, but i will try it when Unity 2018 is released and supports IL2CPP for standalone.

@R1PFake
2018.1 beta with IL2CPP for standalone is already available.

Hello, a few questions about IL2CPP for PC:

  • The Unity roadmap indicate that IL2CPP is coming to Windows and Mac, but not Linux. Why is that? Will it support Linux too at some point?
  • I have currently CPU usage spikes due to the garbage collector in C#. Will switching to IL2CPP fix this issue? Or will it result in memory leaks?
  • I’m currently using Obfuscator for basic scripts protection. Will switching to IL2CPP make it obsolete?
    Thanks!

Right now you can’t cross compile IL2CPP for standalones. That means you can do a Windows Standalone IL2CPP build on Windows. Same for Mac. Doing a Linux Standalone IL2CPP build would require a Linux Editor which is not fully supported ATM.

IL2CPP will not fix garbage collection issues.

IL2CPP is not designed to be an obfuscator, but the native compilation does by it’s very nature improve obfuscation over managed dlls.

At some point, yeah. But as Jonathan mentioned, we still don’t have a supported Linux editor. Furthermore, Linux as a platform is smaller than both Windows and Mac in terms of gamers, so it was naturally lower priority (and we couldn’t do all of them in time).

Not entirely. It’s still possible (and it’s not very complicated) to get your class, method and field names out of compiled binary.

@joncham & @Tautvydas-Zilys : I see. Thanks for the clarification.

Well, I have tried IL2CPP for Windows standalone.

  1. Created a new empty project.
  2. Switched the backend to IL2CPP (the only change I made).
  3. Ran the build process with the default settings.
  4. Build failed.

Errors

Failed running G:\Unity 2018.1\Editor\Data\il2cpp/build/il2cpp.exe --convert-to-cpp --enable-array-bounds-check --compile-cpp --libil2cpp-static --platform="WindowsDesktop" --architecture="x64" --configuration="Release" --outputpath="G:\Unity Projects\Temp 7 (IL2CPP)\Temp/StagingArea/Data\Native\GameAssembly.dll" --cachedirectory="G:\Unity Projects\Temp 7 (IL2CPP)\Assets\..\Library/il2cpp_cache" --map-file-parser="G:\Unity 2018.1\Editor\Data\Tools\MapFileParser\MapFileParser.exe" --assembly="G:\Unity Projects\Temp 7 (IL2CPP)\Temp\StagingArea\Data\Managed\UnityEngine.Analytics.dll" --assembly="G:\Unity Projects\Temp 7 (IL2CPP)\Temp\StagingArea\Data\Managed\UnityEngine.dll" --generatedcppdir="G:\Unity Projects\Temp 7 (IL2CPP)\Temp\StagingArea\Data\il2cppOutput"
stdout:
Building GameAssembly.dll with MsvcDesktopToolChain.
 Output directory: G:\Unity Projects\Temp 7 (IL2CPP)\Temp\StagingArea\Data\Native
 Cache directory: G:\Unity Projects\Temp 7 (IL2CPP)\Library\il2cpp_cache
il2cpp.exe didn't catch exception: System.InvalidOperationException: Builder is unable to build using selected toolchain (MsvcDesktopToolChain) or architecture (Unity.IL2CPP.Common.x64Architecture)!
   at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
   at Unity.IL2CPP.Building.Statistics.BuildingTestRunnerHelper.BuildAndLogStatsForTestRunner(CppProgramBuilder builder, IBuildStatistics& statistics)
   at il2cpp.Program.DoRun(String[] args)
   at il2cpp.Program.Run(String[] args)
   at il2cpp.Program.Main(String[] args)
stderr:
Unhandled Exception: System.InvalidOperationException: Builder is unable to build using selected toolchain (MsvcDesktopToolChain) or architecture (Unity.IL2CPP.Common.x64Architecture)!
   at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
   at Unity.IL2CPP.Building.Statistics.BuildingTestRunnerHelper.BuildAndLogStatsForTestRunner(CppProgramBuilder builder, IBuildStatistics& statistics)
   at il2cpp.Program.DoRun(String[] args)
   at il2cpp.Program.Run(String[] args)
   at il2cpp.Program.Main(String[] args)
UnityEngine.Debug:LogError(Object)
UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:128)
UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action`1) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:73)
UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List`1, Action`1, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:349)
UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(ICollection`1, String, String) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:330)
UnityEditorInternal.IL2CPPBuilder:Run() (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:161)
UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:41)
DesktopStandalonePostProcessor:SetupStagingArea(BuildPostProcessArgs) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs:172)
DesktopStandalonePostProcessor:PostProcess(BuildPostProcessArgs) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs:18)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

That error means it couldn’t find a suitable C++ compiler on your machine. Do you have VS2017 with C++ components installed?

2 Likes

Hm… VS 2017 - yes, C++ components - no. Never thought it’s needed. IL2CPP for Android seemed to work on its own, but I guess the compiler was inside Android NDK.

Thanks!

PS
Works like charm!

Oh, my God . You’re not really arguing about why you need a native build, right? Are you just kidding me?

I was using VS 2015. It occurred error. I removed VS 2015 ( it is very difficult ) and reinstall VS 2017 . It worked.

VS2015 should work too if you install the C++ bits. For 2018.1 release, we aim to support VS2010, VS2013, VS2015 and VS2017.

1 Like

Hello, thanks for info, but wich one tool actualy? I’ve installed:

  • Classic app C++ dev tools
  • Build Tools for vs2017
  • Unity tools
  • Game dev C++ tools

Unity version is 2018.1.0b4

but still getting this error:
https://vk.com/doc14343415_459148810?hash=58ea6c994dd590de34&dl=2ad12b5ba3f78ab3c0
sorry for some reason can’t add an image

That’s a different error. It’s saying you didn’t install IL2CPP components in Unity. Run Unity download assistant again and make sure to tick Windows Support (IL2CPP) checkbox.

[QUOTE="Run Unity download assistant again and make sure to tick Windows Support (IL2CPP) checkbox.[/QUOTE]

Thank you, will make it this way of course. 2018.0 - great update. Thank you for you job (: you’r awesome