Lately i started to work on a project at university regarding concurrent and distributed systems. My task was to pick up a working example of a formula 1 simulation and analyze and extend its functionalities. The project was developed on a Linux environment and used the GTK+ toolkit to create its GUI. That said, using a gnome-based distro like Ubuntu would have been the easiest way to start working on it.
Anyway, i generally try to do everything on my mac before giving up to use another os so i started browsing the Web to look for help to get the GTK library to work on mac (i know, it is possible to use macports or fink but i tend to avoid using packet managers on mac).
After lots of time spent reading misleading guides and useless tutorials i found out you have two options:
- go the “hard way” and install the gtk+ library from sources with all its dependancies (pkgconfig, libiconv, gettext, glib, atk, cairo, pango, ..) like i did at first
- download the less recent package (GTK+ 2.18.5) used also in the R-project with an “easy” installer
Exentially, if you go the easy way, you simply double-click the package and install it. At the end you will have the GTK+ framework installed in /Library/Frameworks
Remember to update your PATH variable to add the new binary directory with:
$ nano ~/.profile
adding this line at the end of the file:
export PATH=/Library/Frameworks/GTK+.framework/Versions/2.18.X11/Resources/bin:$PATH
The sources i had to work on were written using the Ada language so the next step was to install the GNAT toolset which includes a compiler, a nice IDE Gps and many other useful tools.
So, i grabbed the latest version from the AdaCore website, GNAT 2010 (for x86_64-darwin), which actually includes support for Mac OS X Snow Leopard (64 bit).
Its installation is pretty smooth:
$ tar xf AdaCore.tar
$ cd GNAT_GPL
$ tar xf gnat-gpl-2010-x86_64-apple-darwin9.6.0-bin.tar.gz
$ cd gnat-2010-x86_64-apple-darwin9.6.0-bin
$ ./doinstall (*)
then follow the on-screen instructions. As remembered at the end of the installation you MUST update your PATH variable again in order to find the new tools.
export PATH=
(*)Note: if you want to install GNAT in its default location (/usr/local/gnat which is highly recommended) you probably have to launch the install script with super user (root) privileges.
If you did it right, you should be able to start the editor by typing:
$ gps
It will launch inside the X11 environment.
Ok, so i got GTK+ and Ada support but still couldn’t use the library until i installed GtkAda, a wrapper for GTK+ to use with Ada.
As you can see, there is no support in the AdaCore website for GtkAda on mac so we have to go the hard way and compile it from the sources. You may be tempted to download the sources from the Linux x86_64 2010 version but avoid it! If you try, you will get a few errors at compile time:
> gtkitementry.c: In function 'gtk_entry_real_insert_text':
> gtkitementry.c:696: error: 'GtkEntry' has no member named 'n_bytes'
> gtkitementry.c:696: error: 'GtkEntry' has no member named 'text_size'
> ...
Luckily, this bug seems to be solved in the latest version of the sources which can be grabbed directly from their svn repository with:
$ svn checkout http://svn.eu.adacore.com/anonsvn/Dev/trunk/GtkAda
As i write now, revision 162359, is known to work on Snow Leopard. To install GtkAda then type:
$ ./configure --prefix=/usr/local/gtkada
$ make
$ sudo make install
The prefix option points to the directory where GtkAda will be installed; you can change it, but /usr/local is almost always a good choice.
As always, you have to update your PATH variable:
export PATH=/usr/local/gnat/bin:/Library/Frameworks/GTK+.framework/Versions/2.18.X11/Resources/
bin:/usr/local/gtkada/bin:$PATH
and your DYLD_LIBRARY_PATH:
export DYLD_LIBRARY_PATH=/usr/local/gtkada/lib:$DYLD_LIBRARY_PATH
You are done! You should be able to work with GTK+ library simply including it in your Ada project now.
Also this project had more requirements, like the use of XMLAda and PolyOrb, but they will be discussed separately.
