Windows exe 上的 mono AOT 给了我一个 DLL
我在 Windows 上,正在尝试提前编译使用 Mono C# 编译器 gmcs
编译的 Main.exe
(也尝试过 mcs
)代码>)。
>mono --aot Main.exe
Mono Ahead of Time compiler - compiling assembly C:\test\Main.exe
Code: 21 Info: 4 Ex Info: 8 Class Info: 30 PLT: 2 GOT
Info: 6 GOT Info Offsets: 8 GOT: 12
Executing the native assembler: as C:\DOCUME~1\MigueldeIcaza\LOCALS~1\Temp\mono_aot_D2 ID2U -o C:\DOCUME~1\MigueldeIcaza\LOCALS~1\Temp\mono_aot_D2ID2U.o
Executing the native linker: gcc -shared --dll -mno-cygwin -o C:\test\Main.exe.dll C:\DOCUME~1\MigueldeIcaza\LOCALS~1\Temp\mono_aot_D2ID2U.o
Compiled 2 out of 2 methods (100%) Methods without GOT slots: 2 (100%)
Direct calls: 0 (100%) JIT time: 0 ms, Generation time: 0 ms,
Assembly+Link time: 319 ms. GOT slot distribution:
image: 1
但这会产生一个Main.exe.dll
,而我想要一个可执行文件。 这可能吗?
更新:
我通过写保护Main.exe.dll
拦截了AOT/构建过程,现在我有一个mono_aot_FZKP2U.o
但仍然没有运气:
>gcc -o Main2.exe mono_aot_FZKP2U.o
/mingw/lib/libmingw32.a(main.o):main.c:(.text+0x104):
undefined reference to `WinMain@16'
collect2: ld returned 1 exit status`
更新2009-10-30:
阅读Jb Evains的回答后,我再次尝试用mono运行Main.exe.dll,但没有成功。
C:\test>mono Main.exe.dll Mono-INFO: Assembly Loader probing location: 'C:\PROGRA~1\MONO-2~1.3\lib\mono\1. 0\mscorlib.dll'. Mono-INFO: Image addref mscorlib 003E5F48 -> C:\PROGRA~1\MONO-2~1.3\lib\mono\1.0 \mscorlib.dll 00B42BC0: 2 Mono-INFO: AOT failed to load AOT module C:\PROGRA~1\MONO-2~1.3\lib\mono\1.0\msc orlib.dll.dll: The system cannot find the file specified. Mono-INFO: Assembly Loader loaded assembly from location: 'C:\PROGRA~1\MONO-2~1. 3\lib\mono\1.0\mscorlib.dll'. Mono-INFO: Config attempting to parse: 'C:\PROGRA~1\MONO-2~1.3\lib\mono\1.0\msco rlib.dll.config'. Mono-INFO: Config attempting to parse: 'C:\PROGRA~1\MONO-2~1.3\lib\..\etc\mono\a ssemblies\mscorlib\mscorlib.config'. Mono-INFO: Assembly mscorlib 003E5F48 added to domain Main.exe.dll, ref_count=1 Mono-INFO: Config attempting to parse: 'C:\PROGRA~1\MONO-2~1.3\lib\..\etc\mono\c onfig'. Mono-INFO: Assembly Loader probing location: 'Main.exe.dll'. Cannot open assembly 'Main.exe.dll': File does not contain a valid CIL image. Mono-INFO: Unloading domain Main.exe.dll 00B04EA0, assembly mscorlib 003E5F48, r efcount=1 Mono-INFO: Unloading assembly mscorlib [003E5F48]. Mono-INFO: Unloading image C:\PROGRA~1\MONO-2~1.3\lib\mono\1.0\mscorlib.dll [00B 42BC0].
I'm on Windows and I'm trying ahead of time compilation on Main.exe
that's been compiled with the Mono C# compiler gmcs
(also tried mcs
).
>mono --aot Main.exe
Mono Ahead of Time compiler - compiling assembly C:\test\Main.exe
Code: 21 Info: 4 Ex Info: 8 Class Info: 30 PLT: 2 GOT
Info: 6 GOT Info Offsets: 8 GOT: 12
Executing the native assembler: as C:\DOCUME~1\MigueldeIcaza\LOCALS~1\Temp\mono_aot_D2 ID2U -o C:\DOCUME~1\MigueldeIcaza\LOCALS~1\Temp\mono_aot_D2ID2U.o
Executing the native linker: gcc -shared --dll -mno-cygwin -o C:\test\Main.exe.dll C:\DOCUME~1\MigueldeIcaza\LOCALS~1\Temp\mono_aot_D2ID2U.o
Compiled 2 out of 2 methods (100%) Methods without GOT slots: 2 (100%)
Direct calls: 0 (100%) JIT time: 0 ms, Generation time: 0 ms,
Assembly+Link time: 319 ms. GOT slot distribution:
image: 1
but that produces a Main.exe.dll
and I want an executable.
Is that possible?
Update:
I intercepted the AOT/build process by write protecting Main.exe.dll
and now I have a mono_aot_FZKP2U.o
but still no luck:
>gcc -o Main2.exe mono_aot_FZKP2U.o
/mingw/lib/libmingw32.a(main.o):main.c:(.text+0x104):
undefined reference to `WinMain@16'
collect2: ld returned 1 exit status`
Update 2009-10-30:
After reading Jb Evains answer I once again tried to runt the Main.exe.dll with mono with no success.
C:\test>mono Main.exe.dll Mono-INFO: Assembly Loader probing location: 'C:\PROGRA~1\MONO-2~1.3\lib\mono\1. 0\mscorlib.dll'. Mono-INFO: Image addref mscorlib 003E5F48 -> C:\PROGRA~1\MONO-2~1.3\lib\mono\1.0 \mscorlib.dll 00B42BC0: 2 Mono-INFO: AOT failed to load AOT module C:\PROGRA~1\MONO-2~1.3\lib\mono\1.0\msc orlib.dll.dll: The system cannot find the file specified. Mono-INFO: Assembly Loader loaded assembly from location: 'C:\PROGRA~1\MONO-2~1. 3\lib\mono\1.0\mscorlib.dll'. Mono-INFO: Config attempting to parse: 'C:\PROGRA~1\MONO-2~1.3\lib\mono\1.0\msco rlib.dll.config'. Mono-INFO: Config attempting to parse: 'C:\PROGRA~1\MONO-2~1.3\lib\..\etc\mono\a ssemblies\mscorlib\mscorlib.config'. Mono-INFO: Assembly mscorlib 003E5F48 added to domain Main.exe.dll, ref_count=1 Mono-INFO: Config attempting to parse: 'C:\PROGRA~1\MONO-2~1.3\lib\..\etc\mono\c onfig'. Mono-INFO: Assembly Loader probing location: 'Main.exe.dll'. Cannot open assembly 'Main.exe.dll': File does not contain a valid CIL image. Mono-INFO: Unloading domain Main.exe.dll 00B04EA0, assembly mscorlib 003E5F48, r efcount=1 Mono-INFO: Unloading assembly mscorlib [003E5F48]. Mono-INFO: Unloading image C:\PROGRA~1\MONO-2~1.3\lib\mono\1.0\mscorlib.dll [00B 42BC0].
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Mono AOT 编译过程不会创建可执行文件。它确实创建了一个库。如果可能的话,Mono 会自动获取 AOT 代码,您只需像平常一样运行 mono Main.exe 即可。您可以通过指定环境变量 MONO_LOG_LEVEL=debug 来检查 Mono 是否选择了本机代码。
The Mono AOT compilation process doesn't create an executable. It indeed creates a library. Mono automatically picks up the AOTed code if possible, you just have to run mono Main.exe like you would normally do. You can check by specifying the environment variable
MONO_LOG_LEVEL=debug
if Mono picks up the native code.