最快获取 Mono

来源:互联网 发布:linux创建目录 编辑:程序博客网 时间:2024/05/16 18:46
获取 Mono
目前可以通过以下四种途径获取 Mono 软件包 。
?  到 Mono 的官方网站下载发行版安装包:
这里提供了各种不同种类的正式发行版或阶段性发行版,人们可以自由
选择所需要的类型。这里所提供的安装包一般都经过了测试,能正确的
编译和运行。
下载地址在: http://www.go-mono.com/download.html
?  日发行包:
假如你希望能密切的跟踪 Mono 的开发进展,或者你想看到 Mono 的开
发历史脚步,你可以在 http://go-mono.com/daily/ 这个地址获取 M
ono 的日发行包。日发行包包括了每一天 Mono 项目的开发进展。共分
为以下 3 种不同的类型:
Mono: 这是一个可以进行编译的运行时和类库的源代码包(包含了 C#
 的所有二进制控件)。 只要你有一个 C 编译器就可以编译和安装使
用了。最新的版本可以直接通过 http://go-mono.com/daily/mono-la
test.tar.gz 来下载。
MonoCharge: 包含了所有进行编译过的 Mono 的 C# 组件和可执行程序
。可以使用它来全面更新你已安装的 Mono 类库和工具。
最新版本可以直接通过 http://go-mono.com/daily/monocharge-late
st.tar.gz 来下载。
MonoLite: MonoLite 包和 MonoCharge 包一样,也提供了让你更新 M
ono 的能力,不过它只包含了最基本的核心类库 corlib, System, Sy
stem.Xml 和 C# 编译器。
最新版本可以直接通过 http://go-mono.com/daily/monolite-latest
.tar.gz 来下载。
?  通过 CVS 服务器获取 Mono 源码 .
CVS 是一个功能强大的源代码管理服务器。假如你认为每天更新一次的
日发行包还是不能满足你狂热的追求最新代码的需求的话,那么还可以
通过访问 Mono 的 CVS 服务器直接获取 Mono 正在开发中的源代码库
,因为有可能你得到的代码是一分钟前由 Mono 的开发人员刚刚提交上
去的。
在 Linux 下访问:
首先要确认你的系统上已经安装了 CVS 客户端软件,如果没有的话,
可以到 http://www.cvshome.org/ 去下载。
在控制台下输入如下命令:
export CVSROOT=:pserver:anonym...@anoncvs.go-mono.com:/mono c
vs login (系统提示要输入密码,可以直接回车) cvs -z3 co mono

其中的 mono 为项目名称,也可以换成别的项目,例如 mcs 和 gtk-s
harp 。然后就可以看到正在从服务器上下载文件, CVS 会自动在当前
目录下建立一个和服务器上的目录结构保持一致的项目文件目录。
?  CVS 快照
Available for curious developers which do not necessarily wan
t to install the CVS source. Baked daily.
Linux上安装
Mono 的分发包有两种形式,一种是源码包,需要手工进行编译,另一
种是二进制包,可以直接安装。 源码包的适用范围比较广,能够适合
几乎所有的 Linux ,但是步骤比较麻烦,所需时间较长。相反,二进
制包的安装比较简单,但是适用范围比较窄,只能在某些特定的 Linu
x 系统下安装,典型的有 RedHat Linux 的 RPM 安装包。
核心的 Mono 分成了两部分:
?  C 组成部分(包含在 Mono 软件包中)
包含了运行 Mono 的所有必要成分,是 Mono 的运行环境。
?  C# 组成部分(包含在 MCS 软件包中)
包含了类库,编译器等使用 C# 编写的内容部分。
源代码安装:
源代码安装是指下载 Mono 的源代码,然后在本地进行编译,
假如你是下载的 Mono 的压缩安装包,可以输入以下命令进行解压缩:

tar zxfv mono-X.XX.tar.gz
其中 X.XX 是 Mono 的版本号。
解压缩完成后,将会看到在当前目录下的一个子目录,名称一般会是:
 mono-X.XX 。
进入该子目录,输入: ./configure
你将看到类似如下的状态信息:
[root@localhost mono-1.0]# ./configure
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Ma
kefiles... no
checking host platform characteristics... ok
checking for gcc... gcc
checking for gcc... (cached) gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
中间略过 …
config.status: creating Makefile
config.status: creating include/Makefile
config.status: creating include/private/Makefile
config.status: creating doc/Makefile
config.status: executing depfiles commands
config.status: executing default commands
GC: included
ICU: no, if you want full i18n support download it from: http
://oss.software.ibm.com/icu/index.html
NPTL: yes
SIGALTSTACK: yes
Engine: Building and using the JIT
这表示 configure 程序正在配置 Mono 的 Makefile 文件,为下一步
编译 Mono 做好准备。假如在此过程中出现了异常中断,并且目录中也
没有生成 Makefile 文件,则需要根据系统提示找出出现错误的原因,
一般可能是因为缺少某些编译 Mono 所必须的软件,例如假设你没有安
装 Gnome X-Window 的话,则需要手动安装 pkg-config 和 glib-2.0
 ,这两个软件可以分别在 http://www.freedesktop.org/Software/p
kgconfig 和 ftp://ftp.gtk.org 处下载。
接下来就可以开始编译 Mono 了,直接在命令行输入 make ,你可以看
到类似如下的输出信息:
[root@localhost mono-1.0]# make
make all-recursive
make[1]: Entering directory `/mono/mono-1.0'
Making all in libgc
make[2]: Entering directory `/mono/mono-1.0/libgc'
Making all in include
make[3]: Entering directory `/mono/mono-1.0/libgc/include'
gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I../.. -I../../libgc/inc
lude -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/
include -pthread -I/usr/local/include/glib-2.0 -I/usr/local/l
ib/glib-2.0/include -DGC_LINUX_THREADS -DMONO_USE_EXC_TABLES
-D_GNU_SOURCE -D_REENTRANT -fexceptions -D_FILE_OFFSET_BITS=6
4 -g -O2 -fno-strict-aliasing -g -Wall -Wunused -Wmissing-pro
totypes -Wmissing-declarations -Wstrict-prototypes -Wmissing-
prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -W
cast-align -Wwrite-strings -c -o genmdesc-helpers.o `test -f
'helpers.c' || echo './'`helpers.c
/bin/sh ../../libtool --mode=link gcc -g -O2 -fno-strict-alia
sing -g -Wall -Wunused
./genmdesc ./cpu-sparc.md cpu-sparc.h sparc_desc
make all-am
其中的由配置脚本生成的编译信息可能看起来会非常杂乱,不过不用担
心,这些都是很正常的现象。另外在编译过程中,依赖不同性能的机器
,可能需要的的时间会比较长,请耐心等待。
在编译完成之后,可以输入 make install 来进行安装,这个步骤会将
 mono 的一些脚本和可执行程序复制到操作系统可以找得到的地方,默
认情况是: /usr/local/bin 。
现在,你可以在命令行输入: mono ,假如出现了以下帮助信息(其具
体含义在后面章节有详细介绍):
Usage is: mono [options] assembly
Runtime and JIT debugging:
--compile METHOD Just compile METHOD in assembly
--ncompile N Number of times to compile METHOD (default: 1)
--regression Runs the regression test contained in the assemb
ly
--print-vtable Print the vtable of all used classes
--trace[=EXPR] Enable tracing, use --help-trace for details
--compile-all Compiles all the methods in the assembly
--breakonex Inserts a breakpoint on exceptions
--break METHOD Inserts a breakpoint at METHOD entry
--debug Enable debugging support
--stats Print statistics about the JIT operations
Development:
--statfile FILE Sets the stat file to FILE
--aot Compiles the assembly to native code
--profile[=profiler] Runs in profiling mode with the specifie
d profiler module
--graph[=TYPE] METHOD Draws a graph of the specified method:
cfg Control Flow Graph (CFG)
dtree Dominator Tree
code CFG showing code
ssa CFG showing code after SSA translation
optcode CFG showing code after IR optimizations
Runtime:
--config FILE Loads FILE as the Mono config
--verbose, -v Increases the verbosity level
--help, -h Show usage information
--version, -V Show version information
--optimize=OPT Turns on a specific optimization:
peephole Peephole postpass
branch Branch optimizations
inline Inline method calls
cfold Constant folding
consprop Constant propagation
copyprop Copy propagation
deadce Dead code elimination
linears Linear scan global reg allocation
cmov Conditional moves
shared Emit per-domain code
sched Instruction scheduling
intrins Intrinsic method implementations
tailc Tail recursion and tail calls
loop Loop related optimizations
fcmov Fast x86 FP compares
leaf Leaf procedures optimizations
aot Usage of Ahead Of Time compiled code
precomp Precompile all methods before executing Main
那么恭喜,你已经正确的安装完成了 Mono 运行环境,可以在 Linux
下运行和编译 .Net 应用程序了。
卸载 Mono 也很简单,只要输入 make uninstall ,就会自动的删除所
有安装的可执行程序和脚本。如果你希望重新编译安装 Mono ,则可以
先输入: make distclean ,然后按照刚才的顺序输入: ./configur
e , make , make install 。
Windows上安装
Mono 本身是一个跨平台的环境,因此它完全可以在 Windows 平台下运
行,也许你会发出这样的疑问:既然 Windows 平台上已经有了 Micro
soft .Net Framework ,那么为什么我还要在 Windows 下安装 Mono
呢?
这是因为:
1 .虽然 Mono 和 Microsfot .Net 能在大部分的情况下保持兼容,但
Mono 还有它自己的扩展部分,例如数量远远超过 Microsoft .Net
 的数据库提供程序。
2 .方便调试。大部分的程序员还是习惯在 Windows 上进行软件开发
,毕竟 Windows 的开发环境比 Linux 要好得多。比如可以在 Window
s 下使用 Visual Studio 进行开发,然后直接调试对 Mono 的兼容性
问题,而不用再切换到 Linux 下。
3 .可以查看 .Net 的类库源代码。 Mono 是开源项目,意味着你可以
查看到类库的 C# 源代码,而 Microsoft .Net 就不能够看到。对于开
发人员理解 .Net 类库的设计和实现是非常有帮助的。
首先需要到 Mono 的下载页面去下载 Windows 安装软件包,它其实是
一个自解压的压缩包,因此不会在开始菜单程序栏中生成任何的快捷方
式,实际上, Mono 自身还没有任何的图形界面,目前你只能在控制台
中才能正确使用 Mono
目前这个 版本的 Mono 还不是很完善,在安装完成后,如果你直接进
入目录下输入 mono 会产生一些找不到动态连接库的错误,所以还需要
手动添加动态连接库的路径到 path 环境变量中,使用如下命令:
Path=%path%;c:/programe files/mono-1.0/bin;c:/programe files/
mono-1.0/icu/bin
然后再到 bin 目录下执行 mono ,便可以看见正确的帮助提示信息。 

原创粉丝点击