Compiling native under linux


#1

Hello,

I’m pretty new to .net core and I’m a little bit confused

I’m trying to compile an “Hello world” app (test) natively under ubuntu 16.04 and core 1.0.0-preview2-1-003177.
After “compiling”, I get into ubuntu.16.04-x64 folder :

test (which seems to be the dotnet cli executable renamed)
test.dll !? (running file on it gives me “Intel 80386 Mono/.Net assembly, for MS Windows” (Mono ??)

I’m surprised, because I just expected a simple “test” executable :frowning:

I tried too :
dotnet compile –native
But get an error :frowning:

Do I miss something ?


#2

Hi @stef-pellegrino,

Currently the .NET Core 1.0.0-preview2-1-003177 tooling does not have support for compilation to native binaries. The “dotnet build --native” command did exist in early versions of the tooling but that was just a proof of concept and could only compile simple “Hello World” programs.

The version of .NET Core optimized for creating native binaries is still under active development and is yet to be released, it’s called CoreRT.

If you’d still like to distribute applications that don’t require .NET Core to be pre-installed on the user’s computer, you can take a look at Self Contained Deployment, this model packages up the .NET Core runtime and dependencies which must be distributed with the generated native binary.

If you want truly native compilation that produces a SINGLE BINARY, then you’ll have to wait for CoreRT to at least get into preview, which should happen sometime in 2017

– Toni


#3

Thanks for the answer Toni. I’ll wait :slight_smile:

I noticed that all the C# libraries under Linux get the .dll extension… Does it mean that .net core is ruled by then Drawbridge engine ?


#4

I’m not sure what you mean by Drawbridge engine but yeah executable files created in the build output will have the “.dll” extension on all platforms. The dll contain .NET opcodes which are interpreted by the runtime when you run “dotnet path/to/dll” from your terminal.

– Toni


.NET Foundation Website | Blog | Projects | Code of Conduct