Last active
August 29, 2015 14:24
-
-
Save TheAngryByrd/8752e3191341f9a213bb to your computer and use it in GitHub Desktop.
Setup Mono on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
SET CYG_BASH=C:\tools\cygwin\bin\bash | |
::get chocoloately for great good | |
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin | |
::to pretend we're linux | |
choco install cygwin -x86 -y | |
::get mono 4.0.2 | |
choco install mono -version 4.0.2 -y | |
::need checks, the mirror sometimes forgets to install packages | |
"C:\tools\cygwin\cygwinsetup.exe" -q --packages="nano,gcc-mingw,gcc-mingw-core,pkg-config,mingw-zlib1,mingw-zlib-devel" | |
::Check versions | |
ECHO -------Cygwin Version------- | |
%CYG_BASH% -lc "cygcheck -dc cygwin"' | |
ECHO -------Mono Version------- | |
%CYG_BASH% -lc "/cygdrive/c/progra~2/Mono/bin/mono --version" | |
ECHO -------pkg-config Version------- | |
%CYG_BASH% -lc "pkg-config --version" | |
ECHO -------mingw Version------- | |
%CYG_BASH% -lc "i686-pc-mingw32-gcc --version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while getopts e:d: option | |
do | |
case "${option}" | |
in | |
e) exe=${OPTARG};; | |
d) targetdir=${OPTARG};; | |
esac | |
done | |
cd $targetdir | |
if [ -z "$exe" ] && [ $(ls *.exe | wc -l) != 1 ] | |
then exit 1 | |
else | |
exe=$(ls *.exe) | |
fi | |
echo using $exe | |
deps="" | |
if [ $(ls *.dll | wc -l) > 0 ] | |
then | |
for f in *.dll | |
do | |
deps="$deps $f" | |
done | |
fi | |
echo found depdencies $deps | |
#TODOS: Take in bool arg for console app, Take in Output.exe name, bool for SGEN | |
export MONO=/cygdrive/c/progra~2/Mono | |
export PATH=$PATH:$MONO/bin | |
export PKG_CONFIG_PATH=$MONO/lib/pkgconfig | |
export CC="i686-pc-mingw32-gcc -U _WIN32" | |
export AS="i686-pc-mingw32-as" | |
output_name=$exe | |
bundle=bundle | |
mkdir $bundle | |
#HACK: https://stackoverflow.com/questions/20207965/create-c-sharp-executable-with-mkbundle-on-windows | |
#This will throw an error saying pkg-config can't be found | |
mkbundle --deps -oo temp.o $exe $deps | |
#If console app need to pass -mconsole http://mono.1490590.n4.nabble.com/mkbundle-output-exe-does-nothing-td1692228.html | |
$CC -mconsole -g -o $bundle/$output_name -Wall temp.c `pkg-config --cflags --libs mono-2` temp.o | |
echo "Compiled" | |
# Copy mono-2.0.dll here since Output depends on it. | |
cp $MONO/bin/mono-2.0.dll ./$bundle | |
rm temp.c temp.o temp.s | |
# Test output file | |
#./$bundle/$output_name | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Target machines (user machines) require Visual C++ Redistributable Packages for Visual Studio 2013 to run the compiled app.