7

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:

$ 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]

It's in Windows XP.

4

3 に答える 3

13

First of all, prepare development environment:

  1. Install Mono. For example, you have installed it into "C:\Soft\Mono".
  2. Install Cygwin. When selecting which packages to install select following: gcc-mingw, mingw-zlib, pkg-config, nano.
  3. Start Cygwin Bash shell (either using a link or "bash --login -i" command).
  4. Open "$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!
  5. 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
    
  6. Restart Cygwin Bash shell.

After that you can compile your assemblies with "mkbundle":

  1. Perform the following command: "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.
  2. 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
    
  3. 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.

  4. You will get "ResultantBundle.exe". This is your Mono application packed as standalone executable.
  5. It still requires "mono-2.0.dll" and some additional DLL-s and resources you depended on during development (for example, it may require GTK# native DLL-s) but it doesn't require full Mono runtime to run.
于 2010-12-18T11:16:15.853 に答える
1

-zをmkbundleに渡す場合は、-lzをgccに渡す必要があることを追加したかっただけです。winformsとネットアクセスを備えたアプリケーションを正しく動作させるのに問題があり、machine.configをC:\ Mono \ etc \ mono \ 4.0\machine.configからアプリケーションの場所にコピーする必要がありました。次に、-machine-configmachine.configをmkbundleに渡しました。

これらの手順はすべてかなり混乱し、イライラします。mkbundle--deps app.exeと入力するほど簡単ではないのはなぜですか?mkbundleで使用されているテンプレートを変更して自分でコンパイルしようとしましたが、実行されません。私は今までモノソースをダウンロードしてすべてを構築しようと試みましたが、それがうまくいくとは思えません。誰かがmkbundleで何が起こっているのかを説明して、これをとても迷惑にすることができれば、私は貢献したいと思います。

于 2011-09-06T15:18:41.387 に答える
0

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

于 2015-01-23T03:51:41.630 に答える