Skip to content

Instantly share code, notes, and snippets.

@shilrobot
Created June 27, 2012 16:54
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save shilrobot/3005371 to your computer and use it in GitHub Desktop.
Save shilrobot/3005371 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 .
@victorwoo
Copy link

I'm using i686-pc-mingw32-gcc (GCC) 4.7.3 within cygwin (update to Aug. 12, 2013)
And still reports:
i686-pc-mingw32-gcc: error: unrecognized command line option '-mno-cygwin'

@segor
Copy link

segor commented Aug 23, 2013

I'v got the same issue

@futsystems
Copy link

got same issue too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment