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
Depending on your framework version it might work with Wine .Net Framework compability in Wine
depending on what version of .NET it is and what libraries it makes use of you could try running it under Mono without compiling the IL down to native code.
most Linux distributions have it available under their package management systems.
see: http://www.mono-project.com/Main_Page for more details
the alternative is to use NGen to do the compiling (http://blogs.msdn.com/clrcodegeneration/archive/2007/09/15/to-ngen-or-not-to-ngen.aspx). but i'm not sure that would work under WINE.
Perhaps it will run under mono?
Simply not possible. For managed code, you need some kind of VM to run in. In Linux you can use Mono or dotgnu portable.net. Maybe some hyper-advanced version of wine will once be able to run the MS .net framework?
This is probably a difficult solution for you, but I mention it here in the interest of completeness.
You can supposedly wrap a .net application with VMWare's Thinapp. I believe this results in a win32 executable.
https://www.vmware.com/products/thinapp
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_<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);
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)