handmade.network » Forums » Is there a way to compile .net code to native
msmshazan
Shazan Shums
166 posts

Some day I will make quality software.
Programming FTW.

#11356 Is there a way to compile .net code to native
8 months, 1 week ago

I know that when you build a .net app it converts into IL code .Is it possible to compile IL or .net code into native assembly code.

Just being curious on programming....
mmozeiko
Mārtiņš Možeiko
1505 posts
1 project
#11361 Is there a way to compile .net code to native
8 months, 1 week ago

Typically for regular apps this is done with ngen at installation time. It takes your .net assembly and does AOT (ahead of time) compilation to native code. It applies CPU specific optimizations, so generated native code is not really distributable. Here's more information on ngen: https://msdn.microsoft.com/en-us/library/6t9t5wcf.aspx

If you use .NET Core runtime then it should be possible to use crossgen tool to compile native code. Not sure how well it is supported though. I believe officially they support AOT compilation only with CoreRT which is alternative .NET Core runtime. Here's the guide how to use it: https://github.com/dotnet/corert/blob/master/Documentation/README.md

And if you write Windows Store applications then you can use .NET Native (which comes with Visual Studio) to do AOT.
MandleBro
Jack Mott
98 posts
1 project

Web Developer by day, game hobbyist by night. Fond of C and F#

#11362 Is there a way to compile .net code to native
8 months, 1 week ago

mmozeiko
Mārtiņš Možeiko
1505 posts
1 project
#11364 Is there a way to compile .net code to native
8 months, 1 week ago

That is .NET Native which I already mentioned. And it is only for Windows Store apps.