As mentioned, we will use Mono as a development platform for our first programs. Therefore, we will start downloading this tool, installing it and seeing how to use it.
Mono can be downloaded from its official website:
The download link is the upper right part. We must choose the platform we will use. In this text, we will download the latest version for Windows (2.10.5 at the time of this writing).
This is a file near 90 MB in size. When the download is completed, we have to double click the received file and the installation will start (probably after a Windows security warning). Then we will have to accept the license agreement, and we will be asked which installation folder we prefer. As usual, we are proposed to use "Program Files".
Then we have to choose which components we want to install (Mono, Gtk #, XSP). We can install Mono, along with Gtk# libraries for creating user interfaces and XSP (eXtensible Server Pages, a web server). I prefer not install everything. Mono is a must. The creation of user interfaces with Gtk # is beyond the scope intended by this text, but may still be of interest for someone. XSP web server is unnecessary at this point, and it would install a service which might slow down our computer slightly, so prefer not to install it.
Installation is not difficult alter that: we will choose a folder in our Start Menu, see a summary, and then file copying will start. If everything is correct, after a short while we will see a confirmation message, which informs us that the installation is complete.
Mono is ready to use. In our Start menu we should have a new folder called "Mono x.x.x for Windows", (x.x.x would be our version number, such as 2.10.5). In that folder we should be able to find "Mono-x.x.x Command Prompt":
If we click this option, the operating system black screen (the "console") will be displayed, and the "search path" will prepared for us to access the compiler-
We might be taken to a folder inside "Documents and settings" or maybe even to one where we do not have write permission, such as "Windows\System32". If we want to change Mono start folder, we can do by right clicking on "Mono-xxx Command Prompt" from the Start menu and selecting "Properties".
Now we must type our source file. We can use any plain text editor for this. In this first approach, we will use Windows "Notepad". Let’s type:
notepad example01.cs
Notepad should warn us that there is no such file, and ask us if we want to create it. If we answer yes, and we can start typing the previous example.
Then we’ll save the changes, exit "notepad" and we’ll be at the black command prompt screen. The next step is compiling our source file. Now let’s type
gmcs example01.cs
If we see no answer, it means that there are no errors, so a file called "ejemplo01.exe" should have been created. New we could run the program by typing
mono ejemplo01.exe
and the message "Hello" should be displayed on the screen.
If our computer has "Dot Net Framework" installed (it is usual in the latest Windows versions) of Windows), our program should also run correctly if we just type its name:
ejemplo01
Note: If you want a more powerful editor than Windows Notepad, you can try Notepad++, which is free ("open source" actually) and can be easily found on the Internet. Geany is an interesting option, too. And if you prefer an environment from which you can type, compile and test your programs, even if they are large projects, we will discuss later about SharpDevelop and Visual Studio.
No comments:
Post a Comment