Create C# executable with mkbundle on windows

前端 未结 3 839
抹茶落季
抹茶落季 2021-01-01 02:38

Im trying to create an executable from a console application. I have installed mono,cygwin (mingw-gcc, mingw-zlib1, mingw-zlib-devel, pkg-config) and I have added the follow

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-01 03:18

    Howto for mkbundle on cygwin + mingw

    Here you can find an updated howto make mkbundle work on Windows


    First, check your setup:

    • Install Mono/GTK# in a path that doesn't contains spaces (ie not Program Files then)
    • Setup a MinGw/Cygwin working compile chain (as the one for compiling mono on windows).
    • Define the mandatory environment variables for mkbundle:
      • mingw compiler location should be in the Windows PATH (used by cmd)
      • pkg-config should also be in the Windows PATH
    • Use a cygwin script to defined mono and mingw required variables.

    Then you can run:

    mkbundle --deps --keeptemp my.exe my.dll -o bundled.exe
    

    Notes:

    • Copy mono-2.0.dll in the application directory as it should be distributed along the bundled exe

    • You must specify all exe and dll that are needed for the bundle.

    • --keeptemp will keep temp.c and temp.s which could come in handy if mkbundle fail on gcc invocation.
    • If you want to invoke gcc by hand (and it may be needed):
    i686-pc-mingw32-gcc -U _WIN32 -g -o output.exe -Wall temp.c $(pkg-config --cflags --libs mono-2)  temp.o

    Anyone can improve mkbundle

    mkbundle is an open sourced C# console application (on mono github) so it can be easily modified and recompiled depending on your needs. Reading the code could also be helpful to understand how it works underneath.

提交回复
热议问题