. Net, C #, Asp. net Visual Studio follows Microsoft Step by step. It is successful, joyful, and rewarding, but it also has an inexplicable sense of crisis, organizing ideas, and planning the future path: it took about four layers of time to continue to follow Microsoft's pace. under the banner of the Lord Bill, he continued to develop his territory. At the same time, he spent about six minutes shifting his focus to Linux, PHP, C/C ++, distributed File systems look a lot in terms of storage, high concurrency, and Big Data Internet architecture. Of course, there is always a dream, and there is only one step ahead!
As a result, the development environment on Linux has been set up over the past two days. The first is the. NET development environment. Mono has long heard of this thing, citing the introduction on the Internet: Mono is a company initiated by Novell (initiated by ximian and led by Miguel de lcaza, one committed to creating. net open source project used on Linux. It contains a C # Language compiler, a clr runtime, and a group of class libraries, and implements ado net and asp net, developers can use C # To develop programs in Linux. Mono is the. netframework on Linux. The following describes how to install Mono:
In the following machine environment: ubuntu10.04.
1, first go to the official website to download mono, version is: mono-2.6.7.tar.bz2
2. decompress, compile, and install
Root @ localhost:/home/guoyuanwei/ # tar-jxvf mono-2.6.7.tar.bz2
Place the decompressed folder to a common place where the software is stored. My directory is/usr/mysoft/: root @ localhost: /home/guoyuanwei/download # mv mono-2.6.7/usr/mysoft/
Root @ localhost:/usr/mysoft/mono-2.6.7 #./configure -- prefix =/opt/MONO this is the configuration installation directory, ready to install the software under/opt/mono. (Note: G ++ and other related compilation tools are required during the configure compilation process. During the compilation process, you can see the error message, follow the prompts in the error message to install the required tool. For example, here is an error: Configure: Error: You need to install bison, which means that the Bison is missing and only the configuration is installed first. Download bison-2.5.tar.gz for installation .)
# Make
# Make install
Install mono. Run commands
Root @ localhost:/opt/MONO/bin # Check whether the installation is successful. To run the mono command anywhere, modify the environment variable as follows:
# Vim/etc/profile
Add the following configuration at the end of the file:
Mono_home =/opt/mono
Path = $ mono_home/bin: $ path
Classpath =.: $ mono_home/lib/
Export mono_home
Export path
Export classpath
To make the/etc/profile file take effect immediately after modification, run the following command:
# Source/etc/profile
Then, log on again to run the Momo command in any location.
Below are a few simple programs to test whether the mono environment is correctly installed
(1) create a hello. CS file and input the following code: If you are familiar with C # development in Windows, you will know the console program in windows!
using System; public class HelloWorld{static public void Main (){Console.WriteLine ("Hello Mono World");} }
Compile the file: root @ localhost:/home/guoyuanwei/gywstudy # GMCs hello. CS (Note: if the GMCs compiler is not installed at this time, the system will prompt that the program "GMCs" has not been installed yet. You can use the following command to install:
Apt-Get install mono-GMCs. GMCs is a C # compiler that supports 2.0 runtime. The latest version seems to be "DMCS, you can check the official documentation to see which C # features are supported during the 2.0 runtime)
After successful compilation, A hello.exe file will be saved and run the following command to obtain the result.
# Mono hello.exe
Hello mono world
(2) Next we will create an experiment on Windows Forms.
using System;using System.Windows.Forms;public class HelloWorld : Form{static public void Main (){Application.Run (new HelloWorld ());} public HelloWorld (){Text = "Hello Mono World";}}
For Windows form program development, you must install the package of the system. Windows. Forms assembly under Linux, which is actually a GUI development toolkit. However, it is not necessary to develop a Windows form program in Linux. The reason for choosing Mono is to develop efficient software on Linux using the powerful Syntax of C.
Compile: # GMCs hello. CS-PKG: DOTNET (Note: Here is a compilation option-PKG: DOTNET, which is an application that adds an assembly, because the standard Windows form program namespace is used in the program, if the package cannot be found during compilation, it may be an environment variable problem, add an environment variable pkg_config_path =/opt/MONO/lib/pkgconfig. This is my mono installation path, depending on your path)
Run: # mono hello.exe
A form program is displayed.
(3) GTK #
using Gtk;using System; class Hello { static void Main() { Application.Init (); Window window = new Window ("helloworld"); window.Show(); Application.Run (); }}
The above program uses the GTK library, so you need to install GTK # To compile it, and install it according to configuration-> compilation->.
Root @ localhost:/usr/mysoft/gtk-sharp-2.12.11 #./configure -- prefix =/opt/GTK-sharp
I encountered the following error during Configuration:
Checking for csc.exe... no
Configure: Error: You need to install either mono or. NET
This mistake is easy to understand. After a few minutes, I cannot find the csc.exe program. In fact, it is not because the file mono. PC is not found during the configuration process, and this mono. PC is under the mono after installation.
Therefore, you need to modify the environment variable and add a pkg_config_path =/opt/MONO/lib/pkgconfig file in the ETC/profile file.
# Make
# Make install.
With this powerful tool, graphical interface software development in Linux is no longer difficult.
(4) The above encoding, compilation, and running are all completed through the command line. Think about the powerful Visual Studio development tool, which is also available on Linux, that is, monodevelop.