I have written some console \"Hello world\"-like app. and have followed c# cywgwin mono mkbundle windows 7 - cannot compile file answer. But I have got:
$ mk
Just wanted to add that if you pass -z to mkbundle then you'll need to pass -lz to gcc. I had some issues getting an application with winforms and net access to work properly, and I had to copy machine.config from C:\Mono\etc\mono\4.0\machine.config to where my application was. I then passed --machine-config machine.config to mkbundle.
All of these steps are pretty confusing and frustrating, why is not as simple as just typing mkbundle --deps app.exe? I tried making a change to the template used by mkbundle and compiling it myself, but it wont run. I've gone as far now as to download the mono source and attempt to build the whole thing, but I doubt it will work. If anyone can explain what the hell is going on with mkbundle to make this so annoying, I'd be interested in contributing.
First of all, prepare development environment:
C:\Soft\Mono
".bash --login -i
" command).$HOME/.bashrc
" with "nano" ("nano ~/.bashrc
"). Don't use editors which don't preserve end-of-line-s ("CR", "LF", "CR/LF" or other), or it will corrupt the file!Add following lines to the end of the file:
export PKG_CONFIG_PATH=/cygdrive/c/Soft/Mono/lib/pkgconfig
export PATH=$PATH:/cygdrive/c/Soft/Mono/bin
Restart Cygwin Bash shell.
After that you can compile your assemblies with "mkbundle":
mkbundle -c -o host.c -oo bundle.o --deps YourAssembly.exe <additional arguments>
". You also may optionally pass "-z
" to compress resultant bundle. You should get "host.c" and "bundle.o" files.In "host.c" you should remove "_WIN32" "branch" (except "#include <windows.h>
" one). It doesn't work. You may do it just by adding "#undef _WIN32
" right after following lines in it:
#ifdef _WIN32
#include <windows.h>
#endif
So you'll get:
#ifdef _WIN32
#include <windows.h>
#endif
#undef _WIN32
Perform the following command: "gcc -mno-cygwin -o ResultantBundle.exe -Wall host.c
`pkg-config --cflags --libs mono-2|dos2unix`
bundle.o <additional arguments>
". If you added a -z additional argument in step 2, you must add a -lz additional argument in this step.
after you have the temp.o and temp.c, you can add them to visual c++ to make a windows application with other sources.