Last active
November 1, 2018 18:13
-
-
Save lateralusX/a3cff5aa83c1a218d9087db2ac0f685a to your computer and use it in GitHub Desktop.
Build Mono on Windows with 64-bit cygwin.
This file contains hidden or 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
For 32-bit cygwin see current description on web page, | |
http://www.mono-project.com/docs/compiling-mono/windows. Bellow instructions apply to 64-bit cygwin | |
building 32 and 64-bit mono using mingw. | |
Install prerequisite: | |
• A working GIT environment is assumed (GIT can also be installed using chocolatey if needed). | |
• Visual Studio 2015. | |
Cygwin can be installed from cygwin web site. Bellow is using 64-bit cygwin distirbution. | |
Ones 64-bit cygwin has been installed, the following packages should be installed. Bellow will setup both 32 and 64-bit mingw toolchains: | |
setup-x86_64.exe -q -P autoconf,automake,bison,gcc-core,gcc-g++,mingw64-i686-runtime,mingw64-i686-binutils,mingw64-i686-gcc-cor,ming-i686-gcc-g++,mingw64-i686-pthreads,mingw64-i686-w32api,mingw64-x86_64-runtime,mingw64-x86_64-binutils,mingw64-x86_64-gcc-cor,mingw6-x86_64-gcc-g++,mingw64-x86_64-pthreads,mingw64-x86_64-w32api,libtool,make,python,gettext-devel,gettext,intltool,libiconv,pkg-config,git,curl,libxslt | |
Make sure that the following GIT setting is set to avoid issues with line endings: | |
git config --global core.autocrlf input | |
NOTE, mono distribution is optional and not needed if there is an existing mono distribution available on the system. There is also an alternative to work with minimal monolite distribution (see below). | |
Build Mono (32 and 64-bit) using 64-bit cygwin: | |
Build 32-bit mono using 64-bit cygwin with sgen GC, installing build into $PREFIX where mono distribution | |
already exists (replacing). NOTE, in order to keep existing mono distribution untouched, setup a different | |
$PREFIX compare to mono distribution and only set PATH to point to existing mono distribution and not $PREFIX. | |
PATH=$PREFIX/bin:$PATH | |
git clone https://github.com/mono/mono.git | |
cd mono | |
./autogen.sh --prefix=$PREFIX --host=i686-w64-mingw32 --disable-boehm | |
make | |
make install | |
Build 64-bit mono using 64-bit cygwin with sgen GC (NOTE, boehm is not supported on 64-bit windows), installing | |
build into $PREFIX where mono distribution already exists (replacing). NOTE, in order to keep existing mono | |
distribution untouched, setup a different $PREFIX compare to mono distribution and only set PATH to point to | |
existing mono distribution and not $PREFIX. | |
PATH=$PREFIX/bin:$PATH | |
git clone https://github.com/mono/mono.git | |
cd mono | |
./autogen.sh --prefix=$PREFIX --host=x86_64-w64-mingw32 --disable-boehm | |
make | |
make install | |
It is possible to parallelize the cygwin build passing in for example-j8, where 8 in this case is the number | |
of parallel builders to run. | |
All native binaries build with cygwin will get a dependency to cygwins c-runtime, libgcc_s_sjlj-1.dll. This DLL | |
must to be visible for native libraries build using cygwin, or they will fail to execute. It is possible to | |
eliminate this dependency for cygwin binaries by linking towards static c-runtime. This is done by setting, | |
CFLAGS=-static-libgcc, before running autogen.sh, for example: | |
CFLAGS=-static-libgcc ./autogen.sh --prefix=$PREFIX --host=x86_64-w64-mingw32 --disable-boehm | |
NOTE, if cygwin native builds are replaced with Visual Studio build, this dependency is replaced with a dependency | |
to Visual Studios c-runtime. | |
Build Mono (32 and 64-bit, release and debug) using Visual Studio: | |
Cygwin mono build will build all needed native runtime libraries, .NET base class libraries and .NET tests. | |
Native runtime libraries can also be build using Visual Studio solution, but currently .NET libraries and tests can't. | |
In order to make sure .NET libraries are up to date with mono runtime, an initial cygwin build needs to be done | |
(as described above). Once the initial cygwin build is done, it is possible to build only native libraries using | |
Visual Studio solution. It is possible to build both 32 and 64 bit, debug/release independent of toolchain used in | |
initial cygwin build and native binaries build in cygwin can be replaced with binaries build by Visual Studio build. | |
This is handy when developing on the mono runtime making it easy to have all configurations build and available at | |
the same time in Visual Studio (not just the one initially configured in cygwin). | |
The Visual Studio projects has also been upgraded to VS 2015, https://github.com/mono/mono/pull/2972. It has gone through a | |
number of adjustments and can build outside source tree and package and install builds into cygwin install | |
directory if needed. It is also possible to keep the builds isolated and switch between needed versions. | |
For example, using MONO_EXECUTABLE=[PATH TO VS BUILD mono|mono-sgen.exe] environment variable, if running existing | |
cygwin scripts using a specific runtime, or from within Visual Studio as part of debugging the mono runtime. | |
If changes are done to the native code and no newer version of the GIT repro has been fetched or changes has been | |
done to base class libraries or .NET tests that needs a cygwin build, building/rebuilding using Visual Studio solution | |
is enough. If, however there are changes done to the base class libraries or tests, a cygwin build is needed. | |
Updated Visual Studio projects also includes fixes to build all configurations using msbuild on the command line as an | |
alternative to building through the UI. | |
Build 64-bit Mono on Windows using sgen GC (step by step), no mono distribution available. | |
Prerequisites: | |
• GIT. | |
• 64-bit Cygwin. | |
• All packages as listed above. | |
• Visual Studio 2015 (if custom branch is used). | |
Steps: | |
• Open cygwin prompt. | |
• git config --global core.autocrlf input | |
• git clone https://github.com/mono/mono.git | |
• cd mono | |
• export PREFIX=/cygdrive/c/mono-dist | |
• ./autogen.sh --prefix=$PREFIX --host=x86_64-w64-mingw32 --disable-boehm | |
• make get-monolite-latest | |
• make -j8 | |
• make install | |
• Open Visual Studio project msvc/mono.sln | |
• Select configuration to build and make a clean/rebuild all. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment