[cl-gtk2-devel] Build problems

Zach elzacho at gmail.com
Sun Jul 5 22:38:47 UTC 2009


So, I have been looking at building CL-GTK2 on  OS X and realized that I
know nothing about this stuff.  I will just provide a dump of my
understanding of things.  All of this is using a pull from the repo on July
5th, 2009 that I am building on SBCL 1.0.25 on OS X 10.4.  I am in no way a
Mac expert (or fan...), so this should all be taken with a grain of salt.
It's not all bad news, see the end.

I installed a GTK framework.  In OS X a framework is basically a bundle of
libraries and header files (and a few other odds and ends.  The framework
has the following libraries in it:

$ ls /Library/Frameworks/Gtk.framework/Libraries/
libatk-1.0.0.dylib*           libjpeg.62.dylib*
libcairo.2.dylib*             libpango-1.0.0.dylib*
libgdk-pixbuf-2.0.0.dylib*    libpangocairo-1.0.0.dylib*
libgdk-quartz-2.0.0.dylib*    libpixman-1.0.dylib*
libgtk-quartz-2.0.0.dylib*    libpng12.0.dylib*
libigemacintegration.0.dylib* libtiff.3.dylib*
libintl.8.dylib

So it looks like it contains libgtk and libgdk.  There is also a glib
framework (not sure if this was installed with the OS or what) which
contains libraries:

$ ls /Library/Frameworks/GLib.framework/Libraries/
libgio-2.0.0.dylib*     libgmodule-2.0.0.dylib* libgthread-2.0.0.dylib*
libglib-2.0.0.dylib*    libgobject-2.0.0.dylib* libintl.8.dylib

So that looks like everything we need, and they are all native libraries.
If I add the proper lines (:darwin (:framework "GTK")) and (:darwin
(:framework "Glib")) everything builds without warning.  Some examples seem
to do nothing while some appear to perhaps almost work.  The CPU usage
usually jumps up around to 150% (on my dual core).  If I try the "Hello,
World" example from the tutorial:

(gtk:within-main-loop
  (let ((window (make-instance 'gtk:gtk-window
                                                 :title "Hello, world!" )))
    (gtk:widget-show window) ))

A window does appear, but it has no title or buttons for
maximizining/minimizing/closing, so that is weird.  I don't know how to
debug something running in a different thread (the stuff I read on line
regarding SLIME and attaching threads didn't seem to work), so I don't know
what it was doing at 150% CPU load.  Does anyone have any experience with
this?

The fact that it builds and a window actually appears makes me think this
could be fixed with a little work (on my part, maybe).  It would remove a
lot of the dependencies to getting CL application with a GUI running on OS
X, and it will satisfy all the whiny Mac users that don't like windows that
look different than the current Apple UI.

It absolutely works to link these against Fink or MacPorts libraries (or
ones you built from source, if so skilled).  These will have to run
underneath the X11 server (that you run on top of the OS X gui).  This is
less than ideal as it is not as "integrated" with the OS X environment (e.g.
the menu bar is not at the top of the screen and X11 has to be running to
run your program), but it is great that it works.  To do this all we need to
do is add a (:darwin (:or "libxxx.dylib")) to the library definitions.  Of
course it would be up to the user to install these libraries and add the
Fink/MacPorts paths to CFFI:*FOREIGN-LIBRARY-DIRECTORIES*.  I could give you
a (very simple) patch, but I really don't know how... any tips?

Anyway, thanks for putting together this binding,
Zach

2009/7/4 Zach <elzacho at gmail.com>

> I run threaded SBCL on OS X and have had no problems (however, the SBCL
> developers do list it as experimental).  So, maybe this will still work on
> SBCL under OS X.  CMUCL has non-native threads, so I guess that this should
> work there too.  Of course CLISP doesn't have threads... and from what I
> hear ACL has a working GTK interface.
>
> One thought, it seems like even if CL-GTK2 didn't spawn a new thread then
> you could get the same effect by invoking your function via (make-thread
> #'demo-class-browser).
>
> Zach
>
>
> 2009/7/4 Kalyanov Dmitry <kalyanov.dmitry at gmail.com>
>
> On Суббота 04 июля 2009 22:22:17 you wrote:
>> > Thank you for informing me of these new developments.
>> >
>> > I am happy to report that CL-GTK2 builds just fine on my Ubuntu 8.10
>> box.
>> > In addition, the examples seem to work as well.
>> >
>> That's great news!
>>
>> > I think I will enjoy playing with this library (and making some GUI
>> > applications that don't rely on Tk).  I was surprised to see that the
>> > examples spawn a new thread, any reason for that?
>>
>> The primary reason is because of the desire to have the REPL: if GUI is on
>> another thread, then REPL is "alive" whlie the GUI is running, you can
>> manipulate objects, redefine functions, etc. and have the GUI respond to
>> changes (not to all kinds of changes, of course, but e.g. you can redefine
>> the
>> function that is called by GUI without having to close windows and restart
>> application).
>>
>> This is somewhat explained in recently updated version of tutorial at
>> http://common-lisp.net/project/cl-gtk2/tutorial.html (in the "Main loop"
>> section).
>>
>> As far as I know, the only problem this creates is the requirement that
>> the
>> lisp must be multi-threaded. As for SBCL and Clozure CL on Linux, CCL on
>> Mac,
>> Allegro it should work fine (don't know about clisp)
>>
>> >
>> > Also, I will give a stab at getting this to build against the OS X GTK
>> > framework I recently installed.  Perhaps I can increase the number of
>> > platforms this works on.
>>
>> I guess that on OS X it should work. I am not so sure about Windows,
>> however;
>> it will require some work.
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cl-gtk2-devel/attachments/20090705/0c9406ac/attachment.html>


More information about the cl-gtk2-devel mailing list