Wednesday, November 17, 2004

.Net on Unix

First, let me introduce you to my machine:
A dual processor capable machine based on the L440GX+ motherboard. Right now it is only ornamented with one Intel Pentium III 500 MHz processor. I have a Seagate Baracuda 40 GB hard disk drive and 360 MB of RAM. Windows 2000 Professional is installed in the 32 GB primary partition and FreeBSD 4.7 is installed on the Secondary partition which is 8 GB. I had installed FreeBSD 5.1 earlier.
The main reason for installing FreeBSD was that I wanted to work with NCTUns I wanted to get familiar with network simulations on it. Earlier I had used NS-2 and ran mobile IP and mobile ad hoc network simulations on it. It was very difficult to use. It bases its simulations on TCL scripts and its output is a huge trace file (the size depending upon the duration of the simulated test amongst other factors) which contains very raw data, and then you have to make sense of it based on your objectives using some sort of programming. Someone tells me tha Perl would be best, but I havent had any experience with it, so my friend used gawk, C++, sed, shell scripting and what not to extract the end to end delay in a simulation. More on that in some other post. Anyway, NCTUns does not compile on FreeBSD 5.1. I had been needing FreeBSD 4.7 for a long time, talked to many people and then finally stuck my office PC to the campus intranet and left it running overnight to download 2.42 GB of FreeBSD 4.7 ISOs, and here I am with it and NCTUns running.Down to .NET on FreeBSD. There are four .net projects in the open source arena that I am aware of:
1- Mono:
2- OCL - Open CLI Library from Intel :
3- Rotor SSCLI - Shared Source Common Language Infrastructure - from Microsoft:
4- DotGNU:
The DotGNU project consists of various components, some of them optional. The required build is:
treecc - an aspect oriented tool that assists in creating the pnet's compiler cscc
pnet - Portable .NET consists of a runtime engine, a C# compiler, and several useful development tools coded in C
pnetlib - Implementation of the C# System libraries such as mscorlib.dll, System.dll, System.Xml.dll, System.Drawing.dll, System.Windows.Forms.dll etc.
These must be built in the same order as specified above. Optional components include:
PNetMark - a benchmarking tool for the CLR
pnetcurses - a wrapper around ncurses library. Also includes a game called curse of frogger. Coded in C#
cscctest - a regression test tool for the C# compiler
pnetC - cscc has had the ability to compile C code since version 0.4.4 of DotGNU. pnetC is the companion implementation of the C library. There is some early stage compiler plugins for Java and Visual Basic.NET available
ml-pnet - these are some of the upper level libraries of mono distributed in a form that they can be used with the CLI implementation of DotGNU. Also includes ADO.NET with some useful SQL providers such as NPgsql
The DGEE project runs web services. It has the potential to host ASP.NET, but presently does not. You should have Apache installed on your machine as the make script includes a call to a component of Apache. It requires goldwater, a distributed message-based middleware. Obviously, gotldwater must be built first before dgee can be built.One other tar ball that I had downloaded is phlib. I couldnt figure out what it is for.
The build process is the standard ./configure followed by gmake (not make). I had trouble when I ran make, and when I did searches online, I found why I was getting the trouble. We must use gmake. My FreeBSD machine for some reason wasnt having ld load libraries to link from the /usr/local/lib and most of the libraries the compile process wanted were there. I tried the environment variable LD_LIBRARY_PATH but I couldnt get it working. My shell skills are weak and I always get confused with the difference in syntax between the different shells and stuff. So, what I did was either try ./configure --help, which showed me that there was a command line option --libdir=DIR, so I could say ./configure --libdir=/usr/local/lib --includedir=/usr/local/include or I could open the configure script and modify the variable CPPFLAGS to include -L/usr/local/lib -I/usr/local/include. With that, except for some missing dependencies, which will certainly vary from one compilation to another, and took me a lot of time and effort to figure out, everything went well. One tip is, if configure does not succeed, look at the config.log file. It contains traces of command lines that are invoked. I located missing -L directives to the gcc at more times than I care to count, so I opened configure in vi and included the -L in the CPPFLAGS variable as I mentioned before. Also, the stdout does not show you why a program compile test failed in configure, but configure.log contains the output of the gcc program, which will let you know whether gcc can not locate a library or an included header file and then you can go from there. One of the major source of problems to me, especially because it was the first bump for me, was missing glib-2.0. I downloaded the source from and compiled it and faced the problems I outlined above, and finally got it working. So, you might want to make sure you have it on your machine before you start compiling.
Compiling C# programs: I'm mostly interested in C# as the programming language in the .NET arena, even though one of the corner stones of .NET are language interop and independence. Anyway, you can compile C# and C programs using cscc. The usual syntax is:
cscc -o helloworld.exe helloworld.cs
Once you've compiled the program, you can run it by typing
ilrun helloworld.exe
On Linux ILRun can be registered so that you wouldnt have to type ilrun before every managed program, but not on FreeBSD. If you're trying it out on Linux, please read the DotGNU docs. Of course, you can also assemble IL directly using the ilasm tool. Needless to mention, ildasm is also available.
ilasm -o helloworld.exe
ildasm helloworld.exe >
Other tools that I would like to look at later are:
Qt# -
Gtk# -
wx.NET -
CsGL -
C#-SDL -

No comments: