1. Open the mono website: http://download.mono-project.com/sources/mono/, download the source code and compile it
<span style="font-size:18px;">$ wget http://download.mono-project.com/sources/mono/mono-4.6.0.182.tar.bz2
$ tar jxvf mono-4.6.0.182
$ cd mono-4.6.0.182
$ ./configure --prefix=/usr/local
$ make
$ make install
</span>
[Test 1]
After completion. Create a new HelloWorld.cs file
$ gedit HelloWorld.cs
write the following code
<span style="font-size:18px;">using System;
public class HelloWorld
{
static public void Main ()
{
Console.WriteLine ("Hello Mono World");
}
}
</span>
After saving, compile and generate HelloWorld.exe. Use the mono command to run
$ mcs HelloWorld.cs
$ mono HelloWorld.exe For the
old version of mono, please use gmcs to compile
[Test 2] to
call the Winform program.
$ gedit HelloForm.cs
<span style="font-size:18px;">using System;
using System.Windows.Forms;
public class HelloForm : Form
{
static public void Main ()
{
Application.Run (new HelloForm());
}
public HelloWorld ()
{
Text = "Hello Mono World";
}
}
</span>
$ mcs hello.cs -pkg:dotnet35
$ mono HelloWorld.exe //The compilation is successful, but an error is reported when running, which is another problem with the library. . .
2. Use IDE.
Method 1: Monodevelop was
not compiled in the end because of the lack of dependency libraries when I was compiling.
Method 1: eclipse + emonic
emonic plug-in: http://emonic.sourceforge.net/updatesite/nchc/site.xml
Since this plug-in has not been updated for a long time, it does not support the new version of mono. After installation, it is also running. Report an error.
Ugh. . . The version of the donet library has changed, and the IDE installation is complicated, and it is not easy for people to be interested.
[2017 Supplement]
最近才了解到,微软搞了个.net core项目,和mono一样是跨平台.net实现。
net core其内容是windows下的net framework的子集。接力mono,致力于C#跨平台。
对应的开发IDE是VSCode。
其实,在开源界里面,开发者比较喜欢Command Line,而不是GUI。。。
Net Core SDK 还在不断升级和推出新本,这个关系不大,重点,不要像.net framework 和 swift 那样,版本不兼容 和 API 接口更名。。。这样,是不会有人‘了’你的。