Skip to content

Instantly share code, notes, and snippets.

@Anime4000
Forked from shilrobot/package.sh
Created September 23, 2015 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Anime4000/349f8f8bae3d6f2a06b7 to your computer and use it in GitHub Desktop.
Save Anime4000/349f8f8bae3d6f2a06b7 to your computer and use it in GitHub Desktop.
Making mkbundle work on Windows
#!/bin/bash
# If this doesn't work, ensure you have UNIX line endings in this file
# (\n, not \r\n.) You can use Notepad++ to switch them.
# Cygwin package requirements: gcc-mingw, pkg-config
# If you want to pass -z to mkbundle: mingw-zlib1, mingw-zlib-devel
# crash immediately if anything bad happens
set -o errexit
set -o nounset
# progra~2 is Program Files (x86) on Windows x64, except without spaces in it,
# which mkbundle seems to like better.
# Use progra~1 if you have a 32-bit install.
export MONO=/cygdrive/c/progra~2/Mono-2.10.8
# Required to find mkbundle
export PATH=$PATH:$MONO/bin
# Required for the pkg-config call that mkbundle causes to work
export PKG_CONFIG_PATH=$MONO/lib/pkgconfig
# On Cygwin you used to be able to use gcc -mno-cygwin to make binaries
# that didn't depend on cygwin. That doesn't work with the current gcc 4.x,
# so I'm explicitly using the compiler installed by the gcc-mingw package,
# in case the user has normal, non-mingw gcc installed too.
#
# Another alternative would be to use an older version of GCC, e.g:
#
# export CC="gcc-3 -mno-gycgin -U _WIN32"
#
# The -U _WIN32 undefines the _WIN32 symbol. The source code mkbundle executes
# is totally broken on Win32 but actually works if you don't let it know
# that it is on Win32.
export CC="i686-pc-mingw32-gcc -U _WIN32"
# Call Mono's mkbundle with your assemblies.
# --deps tells it to gather dependencies.
# -o specifies the output file name.
# YourGame.exe and OpenTK.dll can be replaced with whatever assemblies you need to include.
# You don't need to specify system assemblies, mkbundle will pick them up because of --deps.
mkbundle YourGame.exe OpenTK.dll --deps -o Output.exe
# Copy mono-2.0.dll here since Output.exe depends on it.
cp $MONO/bin/mono-2.0.dll .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment