Can not compile simple C# application with mkbundle

前端 未结 3 1379
无人及你
无人及你 2020-12-25 10:11

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         


        
3条回答
  •  感情败类
    2020-12-25 10:43

    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 ". 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 " one). It doesn't work. You may do it just by adding "#undef _WIN32" right after following lines in it:

      #ifdef _WIN32
      #include 
      #endif
      

      So you'll get:

      #ifdef _WIN32
      #include 
      #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 ". 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.

提交回复
热议问题