在windows上编译32位和64位mono

18 篇文章 0 订阅

1.从git克隆出源码

git clone https://github.com/mono/mono.git

2.进入源码的msvc目录,打开mono.sln,选择需要的解决方案配置,解决方案平台。编译。


例如

64位:release_sgen,x64

32位:release_sgen,Win32


There are two ways of building Mono on Windows, both do require a Cygwin setup which provides some tools required by Mono at build time. First, download Cygwin from www.cygwin.com. Use the 32 bit installer (setup-x86.exe).

Run the following command in cmd.exe to install the required packages:

setup-x86.exe --root "C:\cygwin" --quiet-mode --packages autoconf,automake,bison,gcc-core,gcc-g++,mingw-runtime,mingw-binutils,mingw-gcc-core,mingw-gcc-g++,mingw-pthreads,mingw-w32api,libtool,make,python,gettext-devel,gettext,intltool,libiconv,pkg-config,git,curl,libxslt

At this point, you can either do a Visual Studio build or you can continue reading the instructions for a Cygwin build.

The following steps assume you’re running in an instance of the Cygwin terminal. Pick an installation directory where you want your new copy of Mono to be installed. Lets call that location PREFIX. Your Mono installation and its dependencies will be installed there.

Building Mono from a Release Package

Mono releases are distributed as .tar.bz2 packages from the Mono web site. Once you have your dependencies installed all you need to do is run the following command where VERSION is the package version number and PREFIX is your installation prefix:

PREFIX=/usr/local
VERSION=4.2.1
tar xvf mono-$VERSION.tar.bz2
cd mono-$VERSION
./configure --prefix=$PREFIX --host=i686-pc-mingw32
make
make install

By the end of this process, you will have Mono installed on your PREFIX directory.

Building Mono From a Git Source Code Checkout

To build Mono from a Git Source Code checkout, you will want to have the official Mono installed on the system and in your PATH, as the build requires a working C# compiler to run.

On Windows, you should set the following Git setting to avoid issues with line endings: git config --global core.autocrlf input

Once you do this, run the following commands, remember to replace PREFIX with your installation prefix that you selected:

PATH=$PREFIX/bin:$PATH
git clone https://github.com/mono/mono.git
cd mono
./autogen.sh --prefix=$PREFIX --host=i686-pc-mingw32
make
make install

See also these articles:


以上为官方文档,编译为windows 32位架构。

64位架构需要安装64位的编译工具链,包括:mingw64-x86_64-binutils、mingw64-x86_64-gcc-core、mingw64-x86_64-gcc-g++

使用Cygwin安装程序安装以上组件。

修改配置命令:

./configure --prefix=$PREFIX --host=x86_64-w64-mingw32

其他过程与32位编译过程一样。


另外:编译完成的mono dll 动态链接库需要生成对应的lib库才能使用,命令:

mono.def文件在源码目录的mscv目录下。

命令:lib /DEF:mono.def /MACHINE:x64


或者安装 perl 执行mscv目录下的脚本 create-windef.pl

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值