Archive for April, 2009

Adobe AIR on Ubuntu and software installation on Linux

Tuesday, April 7th, 2009

I was looking for a twitter application that could be integrated to my desktop environment. Not something web based, or browser based like TwitterFox. twitter.com has a list of desktop applications. Most of these are Adobe Air based. I have set my eye on installing Twhirl. I needed AIR for that.

Adobe Air (Adobe Integrated Runtime) is a cross-platform runtime environment for rich internet applications that can be deployed on the desktop. It is based on Webkit and Flash technologies.

Ubuntu does not come with Adobe Air pre-installed so I looked it up in Synaptic to see if it is available on one of the repositories. Unfortunately it was not. I don’t like it when something does not have ready deb packages because most of the time that means that you will have to either compile the application from source code yourself or install the binaries by simply copying them to some folder. Unless you do that for development or testing purposes it just not worth it.

Adobe AIR installer in action.

Adobe AIR installer in action.

This big difference with the “Windows philosophy” of installing software is often a major point of criticism of Linux. It is true that proprietary software is not that easy to install on Linux as in Windows. But, it is not Linux that should be put to blame. It is those who release ports of their applications to Linux without offering debian or rpm packages, or a proper installation wizard.

Adobe AIR for Linux is an exception that proves that if the vendor is willing, it can provide an easy way to install and integrate to your system.

The Setup screen.

The Setup screen.

I downloaded the installer, named AdobeAIRInstaller.bin. I expected an awful command line installer that would resolve to unnecessary dialogs and file copying. None of  that! I got the same process and same look and feel as the windows installer. A truly cross platform procedure. To my surprise, the installer integrated Adobe AIR to the packaging system with a proper debian package. It also integrated excellently into Gnome creating proper menu entries. The only minus point is that I still had to execute the installer from the command line

Installing Twhirl

Installing Twhirl

When I downloaded Twhirl, I did not expect that it would install itself just by double clicking the twhirl-0.8.6.air file. But it did! I didn’t expect it to update itself so easily neither. It looked and felt exactly the same as when I tried it later on a windows box.

AIR and Twhirl menu entries after setup.

AIR and Twhirl menu entries after setup.

Also, the runtime integrated a debian package to dpkg. Output from apt-cache:

anirothan@monarch:~$ apt-cache --installed --names-only search adobeair
adobeair1.0 - Adobe AIR
anirothan@monarch:~$ apt-cache --installed --names-only search twhirl
de.makesoft.twhirl.0ea062bc275e7ed1e6ec3762effd73c7158adf33.1 - twhirl - a social networking client 

I’m not trying to promote Adobe or anything. Other Adobe products like Adobe Reader do not offer this kind of experience. It just proves my point. Installation of proprietary software can be as easy as in Windows. With all that wizards and stuff. The only thing that is required is the vendor’s commitment in cross-platform development. 

Personally, I think that package repositories, either deb or rpm, are far superior to the installation paradigm promoted in Windows. What can beat a simple apt-get install <software name here>, or a full blown graphical package manager?

Building Mono 2.4 from source on Ubuntu 8.10

Wednesday, April 1st, 2009

Sad to say that the latest versions of Ubuntu and Debian do not provide the latest packages of Mono preferring stability over bleeding edge. Also, according to the packagers’  mailing list it is not an easy task to provide packages for mono and all the software that binds to it.

I am a sucker for bleeding edge, especially when it comes to thinks like Mono. The latest stable release of Mono, version 2.4 has a lot of new features like the C# interactive repl shell, SIMD extensions and better support for C# 3/.NET 3.5 features, like extension methods and LINQ. See the release notes here. I was disappointed when the most recent version of mono debian packages I could find were for the 2.0.1 version on third-party repositories.

What to do then? Download the source, configure and build to run in parallel to the version of mono installed in my Ubuntu desktop (the mono run-time is always installed on Ubuntu by default, even the live CD runs it, since it is needed to run .NET applications, like F-Spot, that have become a standard in the GNOME desktop). It turns out that it’s not that difficult as it sounds.

Step 1: Install prerequisites for compilation.

First of all, you will need to setup the appropriate tools for configuring and compiling source code. You can install these through the Synaptic package manager but for the sake of speed let’s use some command line magik Wink

Open a console and type in the following to install the gcc compiler, and development header files needed to compile the mono compilers, tools and library stack.

user@system$> sudo apt-get update
user@system$> sudo apt-get install build-essential autoconf automake \
bison flex gtk-sharp2-gapi boo gdb valac libfontconfig1-dev \
libcairo2-dev libpango1.0-dev libfreetype6-dev libexif-dev \
libjpeg62-dev libtiff4-dev libgif-dev zlib1g-dev libatk1.0-dev \
libglib2.0-dev libgtk2.0-dev libglade2-dev libart-2.0-dev \
libgnomevfs2-dev libgnome-desktop-dev libgnome2-dev libgnomecanvas2-dev \
libgnomeui-dev libgnomeprint2.2-dev libgnomeprintui2.2-dev \
libpanel-applet2-dev libnautilus-burn-dev librsvg2-dev \
libgtkhtml3.14-dev libgtksourceview2.0-dev libgtksourceview-dev \
libvte-dev libwnck-dev libnspr4-dev libnss3-dev libxul-dev \
libwebkit-dev libvala-dev

This should install all the necessary software and development headers needed for the compilation.

Step 2: Download mono 2.4 source archives.

Go to http://ftp.novell.com/pub/mono/sources-stable/ . You don’t need every archive in that list.
In this guide we will use: mono-2.4.tar.bz2libgdiplus-2.4.tar.bz2gluezilla-2.4.tar.bz2xsp-2.4.tar.bz2mono-tools-2.4.tar.bz2gecko-sharp-2.0-0.13.tar.bz2mono-debugger-2.4.tar.bz2mono-addins-0.4.zipgtk-sharp-2.12.8.tar.bz2gnome-sharp-2.20.1.tar.bz2gnome-desktop-sharp-2.20.1.tar.bz2webkit-sharp-0.2.tar.bz2

Also go to the MonoDevelop website and download the sources for monodevelop 2.0: monodevelop-2.0, monodevelop-debugger-mdb-2.0, monodevelop-debugger-gdb-2.0, monodevelop-database-2.0, monodevelop-java-2.0, monodevelop-vala-2.0

Create a directory in your home directory for the extracted sources, e.g. src/mono-2.4.

user@system$> mkdir -p src/mono-2.4; cd src/mono-2.4

Extract the downloaded archives to that directory.

Step 3: Prepare the parallel environment

Now it’s time to prepare our system for two versions of the mono runtime. A good idea is to install everything related to mono 2.2 to some path like /opt/mono-2.2 and create shell script to load an environment that will use the version located in that path instead of the default installation. That way you will not render your existing mono installation unstable or broken.

Now create a script that will load the separate mono-2.4 environment.

user@system$> cat > mono-2.4-environment
#!/bin/bash
MONO_PREFIX=/opt/mono-2.4
GNOME_PREFIX=/opt/gnome-2.4
export DYLD_LIBRARY_PATH=$MONO_PREFIX/lib:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$MONO_PREFIX/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=$MONO_PREFIX/include:$GNOME_PREFIX/include
export ACLOCAL_PATH=$MONO_PREFIX/share/aclocal
export PKG_CONFIG_PATH=$MONO_PREFIX/lib/pkgconfig:$GNOME_PREFIX/lib/pkgconfig
PATH=$MONO_PREFIX/bin:$PATH
PS1="[mono-2.4] \w @ "

[Press Ctrl+D for EOF to write the file and get back to the prompt]

user@system$> sudo mv mono-2.4-environment /usr/local/bin
user@system$> sudo chmod +x /usr/local/bin/mono-2.4-environment

And create a second script that will load the environment and execute its argurments.

user@system$> cat > mono-2.4
#!/bin/bash
MONO_PREFIX=/opt/mono-2.4
GNOME_PREFIX=/opt/gnome-2.4
export DYLD_LIBRARY_PATH=$MONO_PREFIX/lib:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$MONO_PREFIX/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=$MONO_PREFIX/include:$GNOME_PREFIX/include
export ACLOCAL_PATH=$MONO_PREFIX/share/aclocal
export PKG_CONFIG_PATH=$MONO_PREFIX/lib/pkgconfig:$GNOME_PREFIX/lib/pkgconfig
PATH=$MONO_PREFIX/bin:$PATH

exec "$@"

[Press Ctrl+D for EOF to write the file and get back to the prompt]

user@system$> sudo mv mono-2.4 /usr/local/bin
user@system$> sudo chmod +x /usr/local/bin/mono-2.4

Load the environment:

user@system$> source mono-2.4-environment

After this command, the prompt should change and contain [mono-2.4] to indicate that you are operating in a Mono 2.4 environment.

[mono-2.4] ~ @ cd ~/src/mono-2.4

NOTE! For the sake of readability the prompt indication in the instructions will remain the generic user@system$> but for the rest of the guide you must make sure that you follow each step while in the 2.4 environment.

And now create the directory where everything will be installed:

user@system$> sudo mkdir -p /opt/mono-2.4

Step 4: libgdiplus

Before compiling the main sources of mono we must compile libgdiplus if we want to have an implementation of the System.Drawing namespace.

user@system$> cd libgdiplus-2.4
user@system$> ./configure --prefix=/opt/mono-2.4 --with-pango

The output of the configure script should be something like this:

---
Configuration summary

   * Installation prefix = /opt/mono-2.4
   * Cairo = 1.8.0 (system)
   * Text = pango
   * EXIF tags = yes
   * Codecs supported:

      - TIFF: yes
      - JPEG: yes
      - GIF: yes
      - PNG: yes
      NOTE: if any of the above say 'no' you may install the
            corresponding development packages for them, rerun
            autogen.sh to include them in the build.

---

If any of the options say no then you have a missing dependency. You might want to use the Synaptic package manager to find the appropriate package to install. However, these dependencies are optional.

Now it’s time to build the source.

user@system$> make
user@system$> sudo make install

Step 5: mono-2.4

Now it’s time to compile mono’s main sources which will produce, among others, the c# compilers and the base class libraries.

user@system$> cd ../mono-2.4
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

Verify that the mono compilers have been installed:

user@system$> which gmcs

This should output: /opt/mono-2.4/bin/gmcs
Your existing mono installation will be preserved since everything is installed to the /opt/mono-2.4 directory.

Step 6: gtk+ and gnome

Now it’s turn to compile libraries needed for desktop environment, namely gtk-sharp, gnome-sharp, gnome-desktop-sharp, gtksourceview-sharp.

user@system$> cd ../gtk-sharp-2.12.8
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../gnome-sharp-2.20.1
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../gnome-desktop-sharp-2.20.1
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

Step 7: gluezilla, gecko-sharp, webkit-sharp

Now lets compile libraries for embedding the gecko and webkit html rendering engines.

user@system$> cd ../gluezilla-2.4
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../gecko-sharp-2.0-0.13
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../webkit-sharp-0.2
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

Step 8: build Mono.Addins

Turn to compile the Mono.Addins libraries:

user@system$> cd ../mono-addins-0.4
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

Step 9: build Mono tools

Now it’s turn to compile the marvelous collection of Mono tools, including Gendarme and GSharp (the C# interactive shell).

user@system$> cd ../mono-tools-2.4
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

After this you have installed the gsharp tool. Test it out:

user@system$> gsharp

Play a little with the C# repl Smile Type quit; when you’re done.

Step 10: build Mono XSP

This is actually something very useful. XSP is a standalone web server developed in C#. It can be run through the command line or even embedded into your application by referencing the Mono.WebServer assembly.

user@system$> cd ../xsp-2.4
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

Step 11: build the Mono Debugger

Getting closer to the end of our compilation session, let’s build the mono debugger allowing us to debug the faulty software we write.

user@system$> cd ../mono-debugger-2.4
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

Step 12: build MonoDevelop 2.0

Now what would all this be without a nice IDE? MonoDevelop 2.0 brings us finally debugger support!

user@system$> cd ../monodevelop-2.0
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../monodevelop-debugger-mdb-2.0
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../monodevelop-debugger-gdb-2.0
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../monodevelop-database-2.0
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../monodevelop-java-2.0
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install
user@system$> cd ../monodevelop-vala-2.0
user@system$> ./configure --prefix=/opt/mono-2.4
user@system$> make
user@system$> sudo make install

And… That’s it. You now have a working mono-2.4 environment and an excellent IDE to work with.

You can launch any .NET program with Mono 2.4 with:

user@system$> mono-2.4 PATH_TO_THE_PROGRAM_AND_ITS_ARGUMENTS_IF_ANY

For example to launch MonoDevelop 2.0:

user@system#> mono-2.4 monodevelop

NOTE! This will work only for shell scripts that are normally distributed with mono applications. If you look at /opt/mono-2.4/bin/monodevelop you will see that it is a shell script that essentially runs something like this: mono /opt/mono-2.4/lib/monodevelop/bin/MonoDevelop.exe. Trying to execute a .NET application, e.g. called main.exe, by typing mono-2.4 main.exe will fail. You sould type mono-2.4 mono main.exe instead.

Enjoy hacking!