Unable to compile a simple C # application using mkbundle

I wrote some console application "Hello world". and followed by C # cywgwin mono mkbundle windows 7 - it is impossible to compile the file . But I have:

$ mkbundle -o Fur Furries.exe --deps -z OS is: Windows Sources: 1 Auto-dependencies: True embedding: C:\Monotest\Furries.exe compression ratio: 40.43% embedding: C:\Soft\Mono\lib\mono\4.0\mscorlib.dll compression ratio: 34.68% Compiling: as -o temp.o temp.s gcc -mno-cygwin -g -o Fur -Wall temp.c `pkg-config --cflags --libs mono-2|dos2un ix` -lz temp.o temp.c: In function `main': temp.c:173: warning: implicit declaration of function `g_utf16_to_utf8' temp.c:173: warning: assignment makes pointer from integer without a cast temp.c:188: warning: assignment makes pointer from integer without a cast /tmp/ccQwnxrF.o: In function `main': /cygdrive/c/Monotest/temp.c:173: undefined reference to `_g_utf16_to_utf8' /cygdrive/c/Monotest/temp.c:188: undefined reference to `_g_utf16_to_utf8' collect2: ld returned 1 exit status [Fail] 

This is on Windows XP.

+7
source share
3 answers

First of all, prepare your development environment:

  • Install Mono. For example, you set it to " C:\Soft\Mono ".
  • Install Cygwin. When choosing packages to install, select the following: gcc-mingw, mingw-zlib, pkg-config, nano.
  • Launch the Cygwin Bash shell (using the link or the bash --login -i ).
  • Open " $HOME/.bashrc " with "nano" (" nano ~/.bashrc "). Do not use editors that do not save end-of-line-s ("CR", "LF", "CR / LF" or others), or this will damage the file!
  • Add the 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 the Cygwin Bash shell.

After that, you can compile your builds with "mkbundle":

  • Run the following command: " mkbundle -c -o host.c -oo bundle.o --deps YourAssembly.exe <additional arguments> ". You can also pass " -z " to compress the resulting packet. You should get the files "host.c" and "bundle.o".
  • In "host.c" you must delete the branch "_WIN32" (except for " #include <windows.h> "). This does not work. You can do this by simply adding " #undef _WIN32 " immediately after the following lines in it:

     #ifdef _WIN32 #include <windows.h> #endif 

    So you get:

     #ifdef _WIN32 #include <windows.h> #endif #undef _WIN32 
  • Run 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 the additional argument -z in step 2, you must add the additional argument -lz to this step.

  • You will get "ResultantBundle.exe". This is your Mono application, packaged as a standalone executable.
  • It still requires "mono-2.0.dll" and some additional DLL files and resources that you depended on during development (for example, it may require GTK files with native DLL files), but it does not require full runtime Mono work.
+13
source

Just wanted to add that if you pass -z to mkbundle, you need to pass -lz to gcc. I had problems with the application application with winforms and clean access to work, and I had to copy the machine.config file from C: \ Mono \ etc \ mono \ 4.0 \ machine.config, where my application was. Then I passed --machine-config machine.config to mkbundle.

All these steps are quite confusing and frustrating, why is it not as simple as typing mkbundle --deps app.exe? I tried to make changes to the template used by mkbundle and compile it myself, but it will not work. I went so far as to download the mono source and try to build it all, but I doubt it will work. If anyone can explain what the hell is going on with mkbundle to make it so annoying, I would be interested to contribute.

0
source

after you have temp.o and temp.c, you can add them to visual C ++ to make a windows application with other sources.

0
source

All Articles