[gtkada] Using libglade2 with GtkAda 2.0.0

Ludovic Brenta ludovic.brenta at insalien.org
Sat Feb 15 15:29:57 CET 2003


Hello,

I attended Mark Owen's presentation on GTK+ at the FOSDEM last
week-end.  The presentation was about the basics of programming with the
GTK.  Mark is the maintainer of the GTK packages in Red Hat Linux, and
develops some of Red Hat's configuration GUIs using GTK).  He said two
things that I found interesting:

1) Do not program in C.

Rationale: well, you know.  The inherent unsafely of C, memory
management, pointers.  At Red Hat, they've chosen Python as their
language for application development (as opposed to library development,
for which Mark said C was fine).  I choose Ada :)

2) Do not generate source code from glade; use libglade instead.

The reasons he gave for this are that the code generators for various
languages, even C, are less well tested than libglade.  In particular,
the diff-and-patch based method of altering the generated files is
error-prone.  He also said that the performance hit of loading the XML
file and constructing the GUI at run-time is mostly a myth, as it is
negligible.

This week-end, I've experimented with writing hello world using GtkAda
1.2.12 and libglade 0.17, and found it to be quite easy.  Both packages
are available in Debian woody.  I haven't had any problems.

Now I'm trying to do the same thing with GtkAda 2.0.0 and libglade2
(1.99.10-1 in woody).  I downloaded GtkAda 2.0.0 from the libre web
site, configured it and compiled it.  When I found that hello world
didn't work, I noticed what I think may be a bug in configure:

$ ./configure --prefix=/opt/GtkAda-2.0.0
[...]
checking for libglade-config... /usr/bin/libglade-config
[...]

But libglade-config comes from libglade 0.17, not libglade2! Indeed:

$ libglade-config --cflags --libs
-I/usr/include/gnome-xml -I/usr/include/libglade-1.0
-I/usr/include/gtk-1.2 -I/usr/include/glib-1.2 -I/usr/lib/glib/include
-I/usr/X11R6/include
-L/usr/lib -lglade -L/usr/lib -lxml -lz -L/usr/lib -L/usr/X11R6/lib
-lgtk -lgdk -rdynamic -lgmodule -lglib -ldl -lXi -lXext -lX11 -lm

So, as you can see, GtkAda gets compiled and linked against the old
libglade, which even brings in GTK 1.2:

$ ldd /opt/GtkAda-2.0.0/lib/libgtkada_glade-2.0.so.0
        libglade.so.0 => /usr/lib/libglade.so.0 (0x4000e000)
[...]
        libgtk-1.2.so.0 => /usr/lib/libgtk-1.2.so.0 (0x4054f000)
        libgdk-1.2.so.0 => /usr/lib/libgdk-1.2.so.0 (0x40674000)
        libgmodule-1.2.so.0 => /usr/lib/libgmodule-1.2.so.0 (0x406a9000)
        libglib-1.2.so.0 => /usr/lib/libglib-1.2.so.0 (0x406ac000)

(the GTK 2.0 libraries are _also_ linked in)

According to the documentation for libglade2, the proper way to bring in
the appropriate library is to use:

pkg-config --cflags --libs libglade-2.0

instead of

libglade-config

And indeed, pkg-config with the above arguments yields:

-I/usr/include/libglade-2.0 -I/usr/include/gtk-2.0
-I/usr/include/libxml2 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0
-I/usr/include/pango-1.0 -I/usr/X11R6/include -I/usr/include/freetype2
-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -lglade-2.0
-lgtk-x11-2.0 -lxml2 -lz -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm
-lpangox-1.0 -lpangoxft-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl
-lglib-2.0

It seems to me that the configure script of GtkAda-2.0.0 should be
amended to use pkg-config instead of libglade-config.  Correct?

--
Ludovic Brenta.





More information about the gtkada mailing list