空荡荡的license要实际的多。
今天在freebsd4.7下尝试了一下ms的cli,他是我尝试过的问题最少的一个。
顺便写一下编译过程中碰到的问题。
1。安装。
要求freebsd版本4.5,4.6,建议4.7;
说明文档中要求swap至少256M,RAM 512(建议),我的RAM 256M通过;如果内存比较小,需要更多的swap空间。
硬盘空间1G;
Developer distribution (需要gcc编译器和其他build工具)
freebsd内核编译选项中要求去掉下面的选项:
# To use more memory per process
options MAXDSIZ="(2048*1024*1024)"
options MAXSSIZ="(256*1024*1024)"
options DFLDSIZ="(1024*1024*1024)"
编译前建议你看看解压目录中readfirst.html这个文件。
到msdn上下sscli_20021101.tgz 15M左右。
http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/MSDN-FILES/027/002/097/msdncompositedoc.xml
解压缩到/opt目录下
$cd /opt
$tar xzvf sscli_20021101.tgz
$cd sscli
(我用bash编译,在我的bsd环境中其他的csh有点问题,没时间研究那个env脚本)
freebsd的root csh shell env有点问题,默认是csh,手动切换bash并不会重新初始化该shell的环境变量,会导致sscli的env脚本无法正常设置编译环境变量,需要手动修改一下env中的两个环境变量SH,SHELL
export SH=bash
export SHELL=/usr/local/bin/bash
然后再运行env.sh脚本初始化编译环境;
$ . env.sh
Fastchecked Environment
$./configure --prefix=/opt
$./buildall
编译好的文件在/opt/sscli/build目录下,大概有700多M(包括obj文件),可以用make clean简单清理一下。
其他说明:
ports中有一份老版本的20020619,这是cli的bet版,corel说在4.5上测试通过,我没尝试过,直接用最新20021101版(这是1.0的正式版,内部版本号应该是v1.0.0003)。用port cli编译也有上述环境变量错误,需要自己手动修改一下env。
使用ms cli:
1.初始化cli环境:
使用shell为bash的普通用户登录;
运行sscli目录下的env.sh脚本。(想使用其他的shell看看前面的readfirst.html文件)
编译和运行:
$csc hello.cs
out file: hello.exe
$clix hello.exe
编译和运行时会在你的用户目录下生成一个.rotor%的隐含目录,有兴趣可以去看看。
简单测试:
--------------------------------------------------------------------------------
写个文件:hello.cs
--------------------------------------------------------------------------------
代码:
// file hello.cs
using System;
class MainApp {
public static void Main() {
Console.WriteLine("Hello World!");
}
}
使用shell为bash的普通用户登录
$cd /opt/sscli
$ . env.sh
$csc hello.cs
$clix hello.exe
hello world!
!!很慢!
--------------------------------------------------------------------------------
再来一个helloxml.cs
--------------------------------------------------------------------------------
// file helloxml.cs
代码:
using System;
using System.IO;
using System.Xml;
class MainApp {
public static void Main() {
StringWriter w = new StringWriter();
XmlTextWriter x = new XmlTextWriter(w);
x.Formatting = Formatting.Indented;
x.WriteStartDocument();
x.WriteComment("简单测试");
x.WriteStartElement("信息");
x.WriteStartAttribute("项目", "");
x.WriteString("Rotor");
x.WriteEndAttribute();
x.WriteString("你好 世界!");
x.WriteEndElement();
x.WriteEndDocument();
x.Flush();
Console.WriteLine(w.ToString());
}
}
$csc helloxml.cs
$ clix helloxml.exe
<信息 项目="Rotor">你好 世界!信息>
--------------------------------------------------------------------------------
完整测试:
在sscli目录下有个tests目录;可以用perl运行rrun.pl这个脚本。时间比较长,如果你想验证你的cli是否都正常。在我的freebsd4.7下都通过了。
相关链接:
Microsoft 共享源代码 CLI 实现: http://www.microsoft.com/china/msdn/library/Dndotnet/html/mssharsourcecli.asp
pnet: http://www.southern-storm.com.au/portable_net.html
mono project: http://www.go-mono.com/
|
|