我该如何将.NET exe转换为Win32 exe?(我没有代码) 目的是使用wine在Linux中运行应用程序。 我认为不能在wine中运行.NET exe,而且我不想使用mono。
根据您的框架版本,它可能与Wine兼容。 .Net Framework在Wine中的兼容性
使用静态库的预编译器。在Mono中也称为mkbundle。
Mono带有一个命令行界面,用于将AOT(提前)编译成JIT编译器。您可以使用此功能创建一个静态链接的.o文件,然后使用调用对象文件的mono运行时嵌入器的简单包装器来运行它。如果您随后静态链接到Mono库,则不会有任何外部依赖项安装.NET框架。
当然,您必须发送所有静态链接的库,否则最终会得到一个巨大的exe文件,但是这就是您要求的。
mono --aot=static
static Create an ELF object file (.o) which can be statically linked into an executable when embedding the mono runtime. When this option is used, the object
file needs to be registered with the embedded runtime using the mono_aot_register_module function which takes as its argument the mono_aot_module_<ASSEM‐
BLY NAME>_info global symbol from the object file:
extern void *mono_aot_module_hello_info;
mono_aot_register_module (mono_aot_module_hello_info);
虽然我在Linux上使用过这个,但我不完全确定它在Windows上同样有效。
更新:记得mkbundle工具:
sehe@sehelap:~$ mkbundle --static test.exe -o hello
OS is: Linux
Note that statically linking the LGPL Mono runtime has more licensing restrictions than dynamically linking.
See http://www.mono-project.com/Licensing for details on licensing.
Sources: 1 Auto-dependencies: False
embedding: /home/sehe/test.exe
Compiling:
as -o temp.o temp.s
cc -o hello -Wall `pkg-config --cflags mono` temp.c `pkg-config --libs-only-L mono` -Wl,-Bstatic -lmono -Wl,-Bdynamic `pkg-config --libs-only-l mono | sed -e "s/\-lmono //"` temp.o
Done
sehe@sehelap:~$ ./hello
hello world
sehe@sehelap:~$ ldd hello
linux-gate.so.1 => (0xb7875000)
libdl.so.2 => /lib/libdl.so.2 (0xb785f000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb7845000)
libm.so.6 => /lib/libm.so.6 (0xb781e000)
libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0xb7819000)
librt.so.1 => /lib/librt.so.1 (0xb7810000)
libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0xb7741000)
libc.so.6 => /lib/libc.so.6 (0xb75e4000)
/lib/ld-linux.so.2 (0xb7876000)
libpcre.so.3 => /lib/libpcre.so.3 (0xb75af000)
mkbundle mkbundle --static test.exe -o test
可能比手动编译嵌入包装器更容易 :) - sehe也许可以在Mono下运行?
这是不可能的。对于托管代码,您需要某种VM来运行。在Linux中,您可以使用Mono或dotgnu portable.net。也许某个超级先进版本的Wine将能够运行MS .net框架?