How can I convert a .NET exe to Win32 exe? (I don\'t have the code) The purpose is to run the application in Linux using wine. I presume that .NET exe cannot be run in wine
Use the ahead-of-time compiler with static libraries. A.k.a. mkbundle on mono
Mono comes with a commandline interface to the mono JIT compiler to compile AOT (ahead of time). You can use this to create a statically linked .o that you can then run with a trivial wrapper that invokes the mono runtime embedder with the object file. If you then statically link to the mono libraries, you won't have any external dependencies to an installed .NET framework.
Of course, you will have to ship all the statically linked libraries or end up with a hughe exe but hey, it's what you asked for
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__info global symbol from the object file:
extern void *mono_aot_module_hello_info;
mono_aot_register_module (mono_aot_module_hello_info);
While I used this on linux, I'm not completely sure it works on windows equally well.
Update Remembered the mkbundle tool:
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)