请问单Mkbundle产生本机代码 [英] Does Mono Mkbundle Produce Native Code

查看:152
本文介绍了请问单Mkbundle产生本机代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正常EXE的由单产生在IL.I要生成本地可执行程序,并使用mkbundle产生本地的exe或者我应该使用单AOT。

The normal EXE's generated by mono are in IL.I want to generate Native Executable,does using mkbundle produce native Exe's or should i use Mono AOT.

推荐答案

是的,mkbundle产生本地可执行文件。
为例,在Linux上,这是我的.NET程序集:

Yes, mkbundle produces native executables. For example, on Linux, here is my .NET assembly:

file Agent.exe
Agent.exe: PE32 executable (console) Intel 80386, Mono/.Net assembly, for MS Windows

我告诉 mkbundle 将其编译为本地可执行程序(这里我要补充Common.dll这是一个依赖于我的Agent.exe组装):

I tell mkbundle to compile it to a native executable (here I have to add Common.dll which is a dependency to my Agent.exe assembly):


mkbundle --deps -o Agent Agent.exe Common.dll
   OS is: Linux
   Sources: 3 Auto-dependencies: True
   embedding: Agent/bin/Debug/Agent.exe
   embedding: Agent/bin/Debug/Common.dll
   embedding: /usr/lib/mono/4.5/mscorlib.dll
   embedding: /usr/lib/mono/gac/System.Runtime.Serialization/4.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll
   embedding: /usr/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll
   embedding: /usr/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll
   embedding: /usr/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll
   embedding: /usr/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
   embedding: /usr/lib/mono/gac/System.Security/4.0.0.0__b03f5f7f11d50a3a/System.Security.dll
   embedding: /usr/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll
   embedding: /usr/lib/mono/gac/Mono.Posix/4.0.0.0__0738eb9f132ed756/Mono.Posix.dll
   embedding: /usr/lib/mono/gac/System.Data.Linq/4.0.0.0__b77a5c561934e089/System.Data.Linq.dll
   embedding: /usr/lib/mono/gac/System.Data/4.0.0.0__b77a5c561934e089/System.Data.dll
   embedding: /usr/lib/mono/gac/Mono.Data.Tds/4.0.0.0__0738eb9f132ed756/Mono.Data.Tds.dll
   embedding: /usr/lib/mono/gac/System.Transactions/4.0.0.0__b77a5c561934e089/System.Transactions.dll
   embedding: /usr/lib/mono/gac/System.EnterpriseServices/4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
Compiling:
as -o temp.o temp.s 
cc -ggdb -o Agent -Wall temp.c `pkg-config --cflags --libs mono-2`  temp.o
Done

现在,让我们再次运行文件命令,对产生的'代理'二进制这个时间:

Now, Let's run the file command again, this time against the generated 'Agent' binary:

file Agent
Agent: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=698384c13208eccc609e5a573deeb09ed3420a29, not stripped

注:本机二进制仍取决于libmono(Mono的运行时库),所以它不会在机器上没有工作单的安装工作。

Note : this native binary still depends on libmono (the Mono runtime library), so it won't work on a machine without a working Mono installation.

您可以嵌入但到libmono的二进制文件,并得到一个独立,自成体系使用mkbundle 可执行 - 静态选项

You can however embed libmono into your binary and get an independant, self-contained executable by using mkbundle --static option.

这篇关于请问单Mkbundle产生本机代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆