HOWTO - Building GtkAda project with xcode

October 7th, 2007 at 11:35 · Filed Under Ada, Call Me a Geek, Computing, HOWTO, Hacking, Mac OS X, Software Development 

My current project (here) requires to develop a GUI application for displaying some JPEG images. I intended to develop a native Mac OS X GUI application using Carbon or Cocoa. Since there is no Cocoa binding in Ada, I narrowed down my option to Carbon. I hit on the wall of frustration where Carbon binding on MacAda.org is very old and supports only gnat-3.3 and PPC (I hope I am not wrong on this).

I have to turn to Gtk+ which will require GtkAda and X11 on Mac OS X. I compiled my test code written for GtkAda very well on console. But when I imported the codes into xcode project, it did not compile. I got the following errors:


error: "gtk.ads" must be recompiled ("a-except.ads" has been modified)
error: "gdk.ads" must be recompiled ("a-except.ads" has been modified)
error: "glib.adb" must be recompiled ("a-except.ads" has been modified)
error: "glib-object.adb" must be recompiled ("a-except.ads" has been modified)
error: "glib-type_conversion_hooks.adb" must be recompiled ("a-except.ads" has been modified)
error: "gtkada.ads" must be recompiled ("system.ads" has been modified)
error: "gtkada-bindings.adb" must be recompiled ("a-except.ads" has been modified)
error: "gtkada-c.adb" must be recompiled ("system.ads" has been modified)
...

I sought help from GNAT-OSX mailing list (September 2007 archive), but there was no avail. I spent many days investigating the cause of the errors. I found out that gtkada source codes would be compiled and produced .ali and .o files in the build directory when I used gnatmake to build my GtkAda application.


$ gnatmake testproject.adb `gtkada-config`

To build a GtkAda project in xcode, follow the instructions below:

  1. In the project browser, under the Group & Files column, locate Targets and the your project name. Right click your project name and select Add Link Binary With Libraries. Select GtkAda libraries from /opt/local/lib/gtkada and necessary libraries from /opt/local/lib.
  2. Select your project name and click on the Info button. In Build tab, select Search Paths under Collection. Include /opt/local/include/gtkada in Header Search Paths. Also include /opt/local/lib and /opt/local/lib/gtkada in Library Search Paths.
  3. Select Source in your project. Select Add to Project … in Project menu. Include all the GtkAda source files in /opt/local/include/gtkada.

Comments

2 Responses to “HOWTO - Building GtkAda project with xcode”

  • thomas on November 8th, 2007 2:28 1

    I had tiger and gnat for this OS. Now I m using leoapard and my old compiler doesn’t work of course ^^

    I have found a version of gnat for leopard but it does’nt work too. Can you help me ? (i m french, sorry for my bad english)

  • Adrian Hoe on November 8th, 2007 9:27 2

    Are you running xcode 3? The answer is don’t! The current gnat does not support on Leopard and particularly xcode 3 at this moment.

    You still have to wait a while until a “working” gnat is rolled out for Leopard and xcode 3.

    Sorry!

Leave a Reply