Gtk-Perl now working in Cygwin

Hello All,

I appear to have Gtk-Perl running pretty well under Cygwin on
a Win2k box.

Name-space collisions were a problem since Cygwin is not case

Here is what I did:

1. Get Gnome working under Cygwin (thanks to Steven Obrien for
his work on this - see

2. Get the Gtk-Perl pre-requisites installed (thanks to Michael Graham
for trailblazing - see; the
archive of the thread he started on the Gtk-Perl mailing list in
November got me started).  Note that the Gnome under Cygwin package
handles most of the non-perl packages.

2. Unpack Gtk-Perl-0.7008.tar.gz and make the top level Makefile.  My
GnomePrint installation wasn't detected, so I ended up forcing it
with 'perl Makefile.PL --with-gnomeprint-force'.  I've checked the
final result, and it works fine printing to files, so I think this is

3. Patch Gnome/xs/Gnome.xs and Applet/xs/AppletWidget.xs:

--- Gnome/xs/Gnome.xs.orig      2002-07-14 09:59:54.000000000 +0000
+++ Gnome/xs/Gnome.xs   2002-07-14 10:00:24.000000000 +0000
@@ -9,7 +9,7 @@
 static GnomeUIInfo * svrv_to_uiinfo_tree(SV *data);
 extern void pgtk_menu_callback(GtkWidget *w, gpointer data);

-extern int pgtk_did_we_init_gdk, pgtk_did_we_init_gtk;
+__attribute__((dllimport))extern int pgtk_did_we_init_gdk, pgtk_did_we_init_gtk;
 int pgtk_did_we_init_gnome = 0;

 #define sp (*_sp)

--- Applet/xs/AppletWidget.xs.orig 2002-07-14 09:59:02.000000000 +0000
+++ Applet/xs/AppletWidget.xs   2002-07-14 09:59:36.000000000 +0000
@@ -10,7 +10,9 @@

 #define newSVGnomePanelOrientType newSVPanelOrientType

-extern int pgtk_did_we_init_gnome;
+__attribute__((dllimport))extern int pgtk_did_we_init_gnome;
+__attribute__((dllimport))extern int pgtk_did_we_init_gtk;
+__attribute__((dllimport))extern int pgtk_did_we_init_gdk;
 int pgtk_did_we_init_panel = 0;

 static void start_new_callback(const char * param, gpointer data)

For whatever reason, auto-import did not work for me on these two
files.  Maybe others won't work depending on your set-up.  The
important thing is to make sure there aren't any undefined reference
errors (read the auto-import section of for the correct way
of doing this).  If you're getting tons of errors, it probably
has something to do with not linking everything properly (-lgtk
and -lGtk look the same to Cygwin).  Explicitly adding the static
libraries in the Makefiles is the real key - see below.  I tried
changing the name of the dynamic libraries and linking that way, but
I couldn't get it to work;  perhaps others will have more luck.

If undefined references to library names (e.g., 'libGtk_dll_a_iname')
show up, look for undefined references after them.  The library
name errors seem to be red herrings, and will go away if the
undefined references listed after them are resolved.

4. Modify Makefiles as they are built (modifying only the LDLOADLIBS
variable as required).  Just the static libraries before the first -L
have been added in the lines below.  This step is slow and painful, as
I don't know how to modify the Makefile.PL's, which would allow me to
modify everything at once rather than wait for each Makefile to be
made (this step involves typing 'make', waiting for the Makefile to
be built, modifying it, typing 'make' again, waiting, etc).  Note
that Gtk/Makefile and ./Makefile haven't been modified.

LDLOADLIBS = ../blib/arch/auto/Gtk/libGtk.a -L/usr/X11R6/lib -L/opt/gnome/lib -lgdk_imlib -lgtk -lgdk -lgmodule -lglib -lintl -lXext -lX11
LDLOADLIBS = ../blib/arch/auto/Gtk/libGtk.a -L/usr/X11R6/lib -L/opt/gnome/lib -lgdk_pixbuf -lgtk -lgdk -lgmodule -lglib -lintl -lXext -lX11
LDLOADLIBS = ../blib/arch/auto/Gtk/libGtk.a -L/usr/X11R6/lib -L/opt/gnome/lib -lgtkxmhtml -lXpm -ljpeg -lpng -lz -lSM -lICE -lgtk -lgdk -lgmodule -lglib -lintl -lXext -lX11
LDLOADLIBS = ../blib/arch/auto/Gtk/libGtk.a ../GdkImlib/blib/arch/auto/Gtk/Gdk/ImlibImage/libImlibImage.a -L/usr/X11R6/lib -L/opt/gnome/lib -lgnomeui -lart_lgpl -lgnome -lgnomesupport -lesd -laudiofile -lpopt -lzvt -lSM -lICE -lgdk_imlib -lgtk -lgdk -lgmodule -lglib -lintl -lXext -lX11
LDLOADLIBS = ../blib/arch/auto/Gtk/libGtk.a ../GdkPixbuf/blib/arch/auto/Gtk/Gdk/Pixbuf/libPixbuf.a -L/usr/X11R6/lib -L/opt/gnome/lib -lzvt -lgnomeprint -lgnomeui -lgdk_imlib -lSM -lICE -lgnome -lgnomesupport -lesd -laudiofile -lpopt -lgdk_pixbuf -lgtk -lgdk -lgmodule -lglib -lintl -lXext -lX11 -lart_lgpl -lxml -lz -lfreetype
LDLOADLIBS = ../blib/arch/auto/Gtk/libGtk.a ../Gnome/blib/arch/auto/Gnome/libGnome.a -L/usr/X11R6/lib -L/opt/gnome/lib -lzvt -lpanel_status -lpanel_applet -lcapplet -lgnomeui -lart_lgpl -lgdk_imlib -lSM -lICE -lgtk -lgdk -lgmodule -lintl -lXext -lX11 -lgnome -lgnomesupport -lesd -laudiofile -lpopt -lORBitCosNaming -lORBit -lIIOP -lORBitutil -lglib -lgnorba
LDLOADLIBS = ../blib/arch/auto/Gtk/libGtk.a -L/usr/X11R6/lib -L/opt/gnome/lib -lglade -lxml -lz -lgtk -lgdk -lgmodule -lglib -lintl -lXext -lX11

5. 'make install'

6. Copy blib/arch/auto/Gtk/Gtk.dll, Gnome/blib/arch/auto/Gnome/Gnome.dll,
GdkImlib/blib/arch/auto/Gtk/Gdk/ImlibImage/ImlibImage.dll, and
GdkPixbuf/blib/arch/auto/Gtk/Gdk/Pixbuf/Pixbuff.dll to /opt/gnome/bin.
Luckily, these names don't conflict with the base Gnome libraries,
which have 'cyg' prepended to their names.  I don't know why there is
a dependence on these when I used libGtk.a and friends, but there is...

7. If there are any problems (except the rebasing one - see below) try
running cygcheck.exe on the dll's to make sure that they can find all
of the libraries they need.  This trick also helped me find out why the
XML::Parser package needed for Gtk-Perl wasn't working for me - the
dll it made couldn't find the expat library I had installed; copying
the expat library to the place/name it was looking for got it to work.

8. Rebasing cygwin dll's is an exercise left to the reader - I haven't
done it yet, and the generic script fails with messages like:

C:\cygwin\bin\perl.exe: *** unable to remap C:\cygwin\usr\X11R6\bin\libX11.dll to same address as parent -- 0x1A2B0000

however, the child test you choose seems to run just fine (and
running the tests individually works great).  See the Gnome under
Cygwin page listed above for more on rebasing.

I'm sure this can be improved upon by people that know more than I
about making perl packages and using cygwin libraries, but I think
it's a good start.  Feel free to contact me with questions or


Kevin Moore

kevin moore-and-moore com

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]