转:在windows平台下编译mono

原文地址:http://www.oschina.net/translate/how-to-build-mono-on-windows?cmp

Introduction

This article builds on and updates a number of existing articles which attempt to describe the build process for Mono on Windows.

If you are just looking for Mono 3.4.0 binaries to use, I have provided the resulting binaries from this walk-through here.

The baseline instructions from the Mono project can be found here.

In theory these should be enough to get Mono compiled but, as ever in the real world, things are slightly more complex. As a result others have written pieces on how to build Mono, and I have found "Building Mono on Windows: The Final Battle" particularly useful.

That said, these articles are now a few years old and I ran into various issues building Mono which I have attempted to address with the walk-through below,

译者信息            

介绍

本文综合了很多现有文章并总结了如何在Windows下创建Mono。

如何你想找编译好的Mono 3.4.0版本,请直接访问这里

Mono项目的基础教程在这里可以找到。

理论上,我所提供的这些教程应该足够让你去成功编译Mono了。但是,在实际操作过程中,可能会略微复杂些。所以其他人也提供了一些补充文档,叫我们怎么编译Mono。这其中,这个Building Mono on Windows: The Final Battle"》教程尤其有帮助。

虽然这么说,但是这些教程已经是很多年前的了,使用的过程中难免会遇到问题,针对这些问题,我提供以下详细完整教程。

We are going to look both at building from the current, at the time of writing, Mono release tarball (3.4.0) and then at building the "latest and greatest" directory out of the git repository

The sequence of events is as follows,

  • Install pre-compiled Mono

  • Install & configure Cygwin

  • Retrieve and extract tarball Mono Sources

  • Build and Mono

  • Modify Cygwin/Mono to address any build failures

  • Install Mono and modify installation

  • Fix-ups/workarounds for Xamarin Studio

  • Retrieve and build git Mono Sources

This walk-through has been tested on an x64 machine running Windows 8.1.

译者信息            

我们现从当前的版本(当我写这篇文章时,Mono发布的版本是3.4.0)构建,然后再从git的代码库中构建最新的版本。

主要步骤如下:

  • 安装预编译的Mono

  • 安装&配置Cygwin

  • 下载并解压Mono的源代码

  • 构建Mono

  • 修改 Cygwin/Mono 来解决构建过程中出现的问题

  • 安装 Mono 并修改安装配置

  • 针对Xamarin Studio的一些修改和配置

  • 从git下载源代码,并构建Mono

这个步骤在Windows 8.1 64位的系统下测试可用。

Install pre-compiled Mono binaries

A stable, pre-compiled build of Mono 3.2.3 can be downloaded here. Download and install this.

Check that it runs by opening a Mono command prompt from the start bar and typing

1 mono --version

You should see Mono come up and the 3.2.3 version shown

01 C:\Program Files (x86)\Mono-3.2.3>mono --version
02 Mono JIT compiler version 2.10.9 (tarball)
03 Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-pro
04 ject.com
05         TLS:           normal
06         SIGSEGV:       normal
07         Notification:  Thread + polling
08         Architecture:  x86
09         Disabled:      none
10         Misc:          softdebug
11         LLVM:          supported, not enabled.
12         GC:            Included Boehm (with typed GC and Parallel Mark)
13 C:\Program Files (x86)\Mono-3.2.3>

Install Cygwin

Download and install the 32-bit version of Cygwin, which is a Unix-on-Windows tool-suite and which is used by the Mono build system. The setup bootstrap can be found here.

As you run through the setup process you will be given the option to specify needed packages. The packages we need to build Mono aren't installed by default so make sure to select each of these.

The Mono on Windows instructions give more in depth details, and indicate we need the following

1 autoconf, automake,bison, gcc-core, gcc-g++,mingw-gcc, libtool, make, python,

The Final Battle instructions indicate some additional packages that we also need to have installed

1 gettext-devel, gettext, intltool, libiconv, pkg-config

Other nice to have packages are

1 wget, zip patch, openssh, vim
译者信息            

安装编译好的Mono执行文件

一个稳定并完成编译的Mono 3.2.3可以在这里下载。下载并安装它。

从开始栏打开命令行,之后用一下命令检查它是否正常运行着:

1 mono --version

你应该看到以下信息出现,并且确定版本是3.2.3:

01 C:\Program Files (x86)\Mono-3.2.3>mono --version
02 Mono JIT compiler version 2.10.9 (tarball)
03 Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-pro
04 ject.com
05         TLS:           normal
06         SIGSEGV:       normal
07         Notification:  Thread + polling
08         Architecture:  x86
09         Disabled:      none
10         Misc:          softdebug
11         LLVM:          supported, not enabled.
12         GC:            Included Boehm (with typed GC and Parallel Mark)
13 C:\Program Files (x86)\Mono-3.2.3>

安装Cygwin

下载并安装32位的Cygwin,这是一款在Windows下模拟Unix命令行的工具,我们用它来创建Mono。安装教程可以参考这里

安装过程中,你会被提示要选择安装必要的包。我们创建Mono所需要的包并没有在默认安装设置里,所以我们要手动选择他们。

Mono on Windows教程里提到了很多关于包的细节,这些包应该是:

1 autoconf, automake,bison, gcc-core, gcc-g++,mingw-gcc, libtool, make, python,

在《Final Ba ttle instructions》说提到了这些包:

1 gettext-devel, gettext, intltool, libiconv, pkg-config

另外,我们最好也要这些包:

1 wget, zip patch, openssh, vim

Configure Cygwin

It has been suggested to me on the mono-dev mailing list that Cygwin needs to be configured to mount the host system drive with a "noacl" option, or there may be issues with file accesses For details see here and here.

Following these instructions, open a Cygwin terminal from the start bar and edit /etc/fstab

1 # For a description of the file format, see the Users Guide
2 # http://cygwin.com/cygwin-ug-net/using.html#mount-table
3 # This is default anyway:
4 none /cygdrive cygdrive binary,posix=0,user 0 0

Add in the noacl option as follows

1 # For a description of the file format, see the Users Guide
2 # http://cygwin.com/cygwin-ug-net/using.html#mount-table
3 # This is default anyway:
4 none /cygdrive cygdrive binary,noacl,posix=0,user 0 0

You may then wish to close and reopen the Cygwin terminal to ensure this change takes effect. You can check the changes by running the 'mount' command to see the 'noacl' option in the output.

 

 

 

 

译者信息            

配置 Cygwin

有人通过 mono-dev 的邮件列表向我建议说,Cygwin 应该可以通过配置 "noacl" 选项来挂载系统的宿主系统的磁盘驱动器,否则的话,进行文件访问的时候可能会出问题。你可以点击此处还有此处了解详情。

从开始菜单中打开Cygwin,编辑 /etc/fstab 文件,并按照下面的指示操作:

1 # For a description of the file format, see the Users Guide
2 # http://cygwin.com/cygwin-ug-net/using.html#mount-table
3 # This is default anyway:
4 none /cygdrive cygdrive binary,posix=0,user 0 0

 

把 noacl 选项添加进去,如下所示:

1 # For a description of the file format, see the Users Guide
2 # http://cygwin.com/cygwin-ug-net/using.html#mount-table
3 # This is default anyway:
4 none /cygdrive cygdrive binary,noacl,posix=0,user 0 0

 

你可能需要关掉Cygwin并重新打开它来确保使刚才的修改生效。你可以通过运行 'mount' 命令看一下 'noacl'是否在其输出的内容里面,以便检查配置是否生效。

Retrieve Mono release tarball

At the time of writing the latest Mono sources release tarball is 3.4.0. There is no Windows installer for this build, the latest being 3.2.3. We will build a working set of Mono 3.4.0 binaries here.

Retrieve the Mono 3.4.0 sources from the link here. Extract them to your file-system.

You should retrieve and extract files within Cygwin. It is possible to retrieve and extract files outside of Cygwin but without care you may find that line endings (CRLF) have been modified which will cause problems with the build.

So open the Cygwin terminal

1 $ cd /cygdrive/c $ mkdir monosources$ cd monosources $ wget http://download.mono-project.com/sources/mono/mono-3.4.0.tar.bz2
2 $ tar xjvf  mono-3.4.0.tar.bz2

 

译者信息            

获取 Mono 发行包

当我写这篇文章的时候,Mono的最新发布版本是3.4.0。在Windows下,还没有该版本的安装包,最新的安装包是3.2.3。我们要在这里构建一个3.4.0版本的二进制包。

你可以从这里下载 Mono 3.4.0 的源代码,并把它解压到你的磁盘上。

你需要使用 Cygwin来下载和解压源码。你也可以在Cygwin外部做这些事,但是如果你不注意的话,可能会发现代码中的换行符(CRLF)被修改掉了,这很可能会导致构建失败。

所以,打开 Cygwin 终端命令行:

1 $ cd /cygdrive/c $ mkdir monosources$ cd monosources $ wget http://download.mono-project.com/sources/mono/mono-3.4.0.tar.bz2
2 $ tar xjvf  mono-3.4.0.tar.bz2

Build from Mono release tarball

There can be build errors when building Mono, such as with missing files or with conflicts with Cygwin headers. When errors occur we will address them with the instructions that follow, but for now we will start a build of Mono to see how far we get

We are going to make a destination folder for the Mono 3.4.0 installation, and we are going to configure the build for future installation to that folder, so

1 $ cd /cygdrive/c
2 $ mkdir monoinstall
3 $ cd monosources/mono-3.4.0
4 $ ./autogen.sh --prefix="C:\monoinstall" --with-preview=yes

NOTE: We are using the Win32 path specifier format for --prefix NOT the Cygwin/*nix format.

Autogen should complete successfully and we then configure the build, as recommended by autogen

1 $ ./configure --host=i686-pc-mingw32

At the end of the configuration process we should see something similar to the following.

01 mcs source:    mcs
02  
03    Engine:
04         GC:            sgen and bundled Boehm GC with typed GC and parallel mark
05         TLS:           pthread
06         SIGALTSTACK:   no
07         Engine:        Building and using the JIT
08         oprofile:      no
09         BigArrays:     no
10         DTrace:        no
11         LLVM Back End: no (dynamically loaded: no)
12  
13    Libraries:
14         .NET 2.0/3.5:  yes
15         .NET 4.0:      yes
16         .NET 4.5:      yes
17         MonoDroid:     no
18         MonoTouch:     no
19         Xamarin.Mac:   no
20         JNI support:   no
21         libgdiplus:    assumed to be installed
22         zlib:

Once configuration succeeds we can then begin the build proper with

1 $ make

 

 

 

 

 

 

 

译者信息            

从Mono发布的压缩包中构建

构建Mono的时候可能会出现一些错误,如文件丢失,或者和Cygwin的头文件冲突等。如果出现错误,我们可以按照下面的说明来修正错误,但是我们现在要做的是开始构建Mono,看看我们能走到哪一步。

我们要给 Mono 3.4.0 指定一个目标文件夹,并且我们将要把它设置成安装目录。如下所示:

1 $ cd /cygdrive/c
2 $ mkdir monoinstall
3 $ cd monosources/mono-3.4.0
4 $ ./autogen.sh --prefix="C:\monoinstall" --with-preview=yes

 

注意:我们给 --prefix指定的是Win32指定的路径格式,而不是Cygwin或 *nix的路径格式。

Autogen应该顺利的完成,接下来我们就要配置构建命令了,如autogen推荐的那样:

1 $ ./configure --host=i686-pc-mingw32

 

在配置进程结束的时候,我们能够看到类型下面的一些输出:

01 mcs source:    mcs
02  
03    Engine:
04         GC:            sgen and bundled Boehm GC with typed GC and parallel mark
05         TLS:           pthread
06         SIGALTSTACK:   no
07         Engine:        Building and using the JIT
08         oprofile:      no
09         BigArrays:     no
10         DTrace:        no
11         LLVM Back End: no (dynamically loaded: no)
12  
13    Libraries:
14         .NET 2.0/3.5:  yes
15         .NET 4.0:      yes
16         .NET 4.5:      yes
17         MonoDroid:     no
18         MonoTouch:     no
19         Xamarin.Mac:   no
20         JNI support:   no
21         libgdiplus:    assumed to be installed
22         zlib:

 

一旦配置结束,我们就可以用以下方式来开始构建进程了。

1 $ make

Build failure #1 - PEXECUTION_STATE

 

 

 

The first build failure is due to an interaction between the Mono definition of PEXECUTION_STATE and the Cygwin definition of the same variable. This results in a failure to build with error output similar to this

01 /usr/i686-pc-mingw32/sys-root/mingw/include/ddk/ntapi.h:49:15:
02     error: conflicting types for 'PEXECUTION_STATE'
03     In file included from
04     /usr/i686-pc-mingw32/sys-root/mingw/include/windows.h:62:0,
05                      from
06     /usr/i686-pc-mingw32/sys-root/mingw/include/winsock2.h:40,
07                      from ../../mono/io-layer/io-layer.h:24,
08                      from ../../mono/metadata/domain-internals.h:15,
09                      from ../../mono/metadata/metadata-internals.h:8,
10                      from ../../mono/metadata/class-internals.h:10,
11                      from ../../mono/metadata/object-internals.h:8,
12                  from process.c:16:

 

The recommended workaround is to edit the Cygin header file, within Cygwin to change the definition of PEXECUTION_STATE to something else, e.g.

1 $ nano /usr/i686-pc-mingw32/sys-root/mingw/include/ddk/ntapi.h

 

Change

1 /* FIXME: Unknown definitions */
2 typedef PVOID POBJECT_TYPE_LIST;
3 typedef PVOID PEXECUTION_STATE;
4 typedef PVOID PLANGID;

 

to read

1 /* FIXME: Unknown definitions */ 
2 typedef PVOID POBJECT_TYPE_LIST; 
3 typedef PVOID PEXECUTION_STATE_WORKAROUND; 
4 typedef PVOID PLANGID;

 

Now kick off the build process again with

1 $ make

 

Install build Mono files

Once the build has successfully completed you can then go ahead and install to the target folder.

First we will need to mount the folder within Cygwin, using

1 $ mount "C:\monoinstall" /usr/local

 

NOTE: I have found that if I have this mounted during the preceding build process then I get errors relating to libiconv. This may be addressed with the 'noacl' fix but for now the suggestion is that the mount should not be made until after make has completed successfully and we areready to install.

 

 

译者信息            

安装失败 #1 - PEXECUTION_STATE

第一个安装失败是由于在Mono中定义的 PEXECUTION_STATE 和在 Cygwin 中定义的同名变量冲突了。具体的错误输出信息类似下面这样:

01 /usr/i686-pc-mingw32/sys-root/mingw/include/ddk/ntapi.h:49:15:
02     error: conflicting types for 'PEXECUTION_STATE'
03     In file included from
04     /usr/i686-pc-mingw32/sys-root/mingw/include/windows.h:62:0,
05                      from
06     /usr/i686-pc-mingw32/sys-root/mingw/include/winsock2.h:40,
07                      from ../../mono/io-layer/io-layer.h:24,
08                      from ../../mono/metadata/domain-internals.h:15,
09                      from ../../mono/metadata/metadata-internals.h:8,
10                      from ../../mono/metadata/class-internals.h:10,
11                      from ../../mono/metadata/object-internals.h:8,
12                  from process.c:16:

 

推荐的做法是修改 Cygwin的头文件,在Cygwin中可以通过以下方法修改 PEXECUTION_STATE 的定义:

1 $ nano /usr/i686-pc-mingw32/sys-root/mingw/include/ddk/ntapi.h

 

将下面的内容:

1 /* FIXME: Unknown definitions */
2 typedef PVOID POBJECT_TYPE_LIST;
3 typedef PVOID PEXECUTION_STATE;
4 typedef PVOID PLANGID;

 

修改为:

1 /* FIXME: Unknown definitions */ 
2 typedef PVOID POBJECT_TYPE_LIST; 
3 typedef PVOID PEXECUTION_STATE_WORKAROUND; 
4 typedef PVOID PLANGID;

 

现在可以重新开始编译进程了

1 $ make

 

安装构建 Mono 文件

等到编译顺利结束,你就可以将其安装到指定的目录了。

首先,要在Cygwin中挂载目标文件夹,如下所示:

1 $ mount "C:\monoinstall" /usr/local

 

注意:我发现,如果在编译之前就挂载目标文件夹,会得到一个和 libiconv 相关的错误。这可能和 'noacl' 有关系,所以,我建议大家还是等到编译顺利完成并且准备去安装的时候再去挂载目标文件夹。

Installation failure #2 - Missing target file

There is a missing file that should be present in the Mono 3.4.0 release tarball. For details see here.

You need to add this file in manually by creating a file

1 $ nano mcs/tools/xbuild/targets/Microsoft.Portable.Common.targets

 

This file should contain the following

1 <Project xmlns=<a class="moz-txt-link-rfc2396E" href="http://schemas.microsoft.com/developer/msbuild/2003">"http://schemas.microsoft.com/developer/msbuild/2003">
2     <Import Project="..\Microsoft.Portable.Core.props" />
3     <Import Project="..\Microsoft.Portable.Core.targets" />
4 </Project>

Install the files

1 $ make install

 

Fix-up: Installation issues - mono.exe

For some reason the installation does not copy across a Win32 executable mono.exe.

This appears to be a stub function and can be copied across from your existing Mono installation, e.g.

1 copy C:\Program Files (x86)\Mono-3.2.3\bin\mono.exe to C:\monoinstall\bin

 

With this fix-up in place you can now execute Mono under Windows and check you have the correct version. Open a Windows command box and type

1 cd c:\monoinstall\bin
2 mono --version

 

You should see something similar to the following

01 Mono JIT compiler version 3.4.0 (tarball)
02 Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
03         TLS:           normal
04         SIGSEGV:       normal
05         Notification:  Thread + polling
06         Architecture:  x86
07         Disabled:      none
08         Misc:          softdebug
09         LLVM:          supported, not enabled.
10         GC:            sgen

 

译者信息            

安装失败 #2 -缺少目标文件

有一个丢失的文件应该是存在于Mono 3.4.0发行版tar包。有关详细信息,请参阅这里。

你需要手动地创建这个文件然后添加这个文件。

1 $ nano mcs/tools/xbuild/targets/Microsoft.Portable.Common.targets

这个文件必须包含下列内容

1 <Project xmlns=<a class="moz-txt-link-rfc2396E" href="http://schemas.microsoft.com/developer/msbuild/2003">"http://schemas.microsoft.com/developer/msbuild/2003">
2     <Import Project="..\Microsoft.Portable.Core.props" />
3     <Import Project="..\Microsoft.Portable.Core.targets" />
4 </Project>

安装这个文件

1 $ make install

修正了:安装问题 - mono.exe

出于某种原因,安装时可执行文件mon.exe无法复制到win32文件夹下。

这似乎是一个保留功能,可通过当前Mono安装被复制,

例如

1 copy C:\Program Files (x86)\Mono-3.2.3\bin\mono.exe to C:\monoinstall\bin

用此修复程序,你可以再windows下执行Mono,并且检查你的正确版本。打开一个Windows命令框中,键入

1 cd c:\monoinstall\bin
2 mono --version

你的应该会看到类似下面的结果

01 Mono JIT compiler version 3.4.0 (tarball)
02 Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
03         TLS:           normal
04         SIGSEGV:       normal
05         Notification:  Thread + polling
06         Architecture:  x86
07         Disabled:      none
08         Misc:          softdebug
09         LLVM:          supported, not enabled.
10         GC:            sgen

Fix-up: Xamarin Studio - extraneous symlink file prevents addition of run-time

If you now try to add this Mono 3.4.0 runtime to Xamarin Studio using Tools->Options, Projects->.NET Runtimes, Add, this will fail with an error message "Mono runtime not found"

This is because of the presence of an extraneous symlink file copied across during the installation.

You may not be able to see this with Windows Explorer or dir in a command box, although dir /a should show it.

If you have trouble deleting under Windows, then use a Cygwin terminal and enter

1 $ cd /cygdrive/monoinstall/bin
2 $ rm mono

 

You should now be able to add the runtime to Xamarin Studio.

Workarounds: Issues with building projects under Xamarin Studio

(1) Mono 3.x fails to build projects for me with recent Xamarin Studio builds. The error given is
Build failed. Could not find type 'System.Globalization.SortVersion'. This appears to be addressed in this commit which is not present in 3.4.0
The workaround is to use an older version of Xamarin Studio as discussed here
i.e. Download Xamarin Studio 4.2.3 from your account at Xamarin.com with "view all versions"
(2) You may then get a build error about UNC paths
error : Error building target GetReferenceAssemblyPaths: UNC paths should be of the form \\server\share

This appears to relate to extra \\'s in configuration files as discussed here

The workaround is to go to project options and unback "Use MSBuild engine" at which point you will be able to compile and debug applications

译者信息            

修正:Xamarin Studio- 防止运行时的无关符号连接

如果你试图通过 Xamarin Studio 的Tools->Options,Projects->.NET Runtime添加Mono 3.4.0 runtime 时,将会失败并弹出一个错误信息"Mono runtime not found"。

这是因为安装时有额外的符号连接文件被复制。

你可能并不希望在资源管理器或者命令框的dir命令中看到这些,尽管dir /a 应该显示它。

如果你在 Windows下删除这些有困难,可以使用 Cygwin terminal 然后键入下面命令

1  cd /cygdrive/monoinstall/bin
2 $ rm mono

现在你可以为 Xamarin Studio添加 runtime。

工作区:在Xamarin Studio下构建项目问题

(1)Xamarin Studio 使用Mono 3.x构建项目将会失败,错误信息是编译失败,未能找到"System.Globalization.SortVersion"类型。这种问题已经添加到反馈中并且不会在3.4.0中出现。

适用于旧版本Xamarin Studio的工作区请点击这里 参与讨论。

例如,使用你的帐户在 Xamarin.com的view all version里下载 Xamarin Studio 4.2.3。

(2)你可能随后得到一个关于UNC paths的编译错误。

error : Error building target GetReferenceAssemblyPaths: UNC paths should be of the form \\server\share

这种情况的出现与配置文件中额外的\\'s有关,请点击这里参与讨论。

解决方法是去除工作区中项目选项中的 "Use MSBuild engine",此时你就可以编译和调试程序。

Building Mono from the git repository

At the time of writing the sequence of events is similar to building from the 3.4.0 release tarball. It is likely that as time moves on existing build issues will be addressed and there may be new build issues encountered so my suggestion is that you start by checking out the same git hash as the one used in this walk-through, verify that builds (3.4.1) and then try again having checked out master.

As detailed above, you will need the Cygwin packages installed, and the modification to PEXECUTION_STATE.

Open up a Cygwin terminal and

1 $ cd /cygdrive/c/monosources
2 $ git clone git://github.com/mono/mono.git

 

We are working with git checkout 079c2e126f594c5a338a779c72a899951de38960.

You may choose to check this out too with

1 $ cd mono 
2 $ git checkout 079c2e126f594c5a338a779c72a899951de38960

 

Make sure /usr/local is not mounted or you may get libiconv-related build failures

1 $ umount /usr/local

 

Then setup and kick-off the build

1 $ ./autogen.sh --prefix="C:\monoinstall" --with-preview=yes
2 $ ./configure --host=i686-pc-mingw32
3 $ make

 

Post-build you will need to mount /usr/local, install the files, add mono.exe and remove the symlink as detailed above

1 $ mount "C:\monoinstall" /usr/local   
2 $ make install
3 $ cd /cygdrive/c/monoinstall/bin
4 $ rm mono
5 $ cp /cygdrive/c/Program Files (x86)/Mono-3.2.3/bin/mono.exe /cygdrive/c/monoinstall/bin

 

At this point you should have the latest and greatest Mono ready to run! You can open a Windows cmd box and enter

1 C:\> cd c:\monoinstall\bin 
2 C:\monoinstall\bin> mono --version

 

You may now wish to checkout the git master within the Cygwin terminal and build the very latest Mono sources.

1 $ cd /cygdrive/c/monosources/mono
2 $ git checkout master

 

Feedback

It is my intention to try to maintain and update this document as new releases of Mono become available.

Please feel free to feed back all corrections, questions and comments to me here.

History

11/05/2014 Initial Release

译者信息            

在git仓库上构建Mono项目

编写代码的时间序列类似于3.4.0 release tarball的构建。随着时间的推移,已存在的版本会被标记,新版本会不断产生,因此我的建议是你在整个项目中一开始就使用同样的git hash去比对文件,验证编译版本(3.4.1)并且再次检查我们的主版本。

详细阐述上面所提及的,你需要安装一个Cygwin packages,并且修改PEXECUTION_STATE。

打开Cygwin terminal并键入如下命令

1 $ cd /cygdrive/c/monosources
2 $ git clone git://github.com/mono/mono.git

我们会和git一起验证 079c2e126f594c5a338a779c72a899951de38960。

你也可以选择验证这个

1 $ cd mono 
2 $ git checkout 079c2e126f594c5a338a779c72a899951de38960

确保 /usr/local没有被挂载,否则你会得到一个 libiconv-related 编译失败的信息。

1 $ umount /usr/local

然后设置和启动编译

1 $ ./autogen.sh --prefix="C:\monoinstall" --with-preview=yes
2 $ ./configure --host=i686-pc-mingw32
3 $ make

编译后你需要挂载 /usr/local,安装程序,添加 mono.exe并移除上面提到的符号链接

1 $ mount "C:\monoinstall" /usr/local   
2 $ make install
3 $ cd /cygdrive/c/monoinstall/bin
4 $ rm mono
5 $ cp /cygdrive/c/Program Files (x86)/Mono-3.2.3/bin/mono.exe /cygdrive/c/monoinstall/bin

这时你已经拥有最新的和最优秀的 Mono程序运行!你可以打开一个cmd窗口并且键入

1 C:\> cd c:\monoinstall\bin 
2 C:\monoinstall\bin> mono --version

你现在可能期望用 Cygwin terminal 检查git的主版本并且编译最新的 Mono源码。

1 $ cd /cygdrive/c/monosources/mono
2 $ git checkout master

反馈

我写这篇文章的意图是更新和维护这篇文档,使Mono程序的发行更适宜利用。

请反馈修正,有什么问题或者建议请点击这里.

历史

11/05/2014 初始发表

posted @ 2014-07-12 17:10  0odrifto0  阅读(1098)  评论(0编辑  收藏  举报