[racket-dev] up-to-date libgtk for drracket on debian stable?

From: Philippe Meunier (meunier at ccs.neu.edu)
Date: Sat Jan 1 10:56:18 EST 2011

John Clements wrote:
>Debian is a slow-moving distribution, and it looks to me like the
>version of libgtk in the stable version of Debian Lenny isn't new
>enough for DrRacket. Here's what I get on startup:

On a related note, I just tried to compile DrRacket on a week-old
OpenBSD 4.8-current and got the following error when starting

ffi-lib: couldn't open "libcairo.so.2" (File not found)
 === context ===
/home/meunier/lang/plt/collects/racket/draw/unsafe/cairo.rkt: [running body]
/home/meunier/lang/plt/collects/racket/draw/private/font.rkt: [traversing imports]
/home/meunier/lang/plt/collects/racket/draw/private/post-script-dc.rkt: [traversing imports]
/home/meunier/lang/plt/collects/racket/draw.rkt: [traversing imports]
/home/meunier/lang/plt/collects/mred/private/kernel.rkt: [traversing imports]
/home/meunier/lang/plt/collects/mred/private/const.rkt: [traversing imports]
/home/meunier/lang/plt/collects/mred/private/check.rkt: [traversing imports]
/home/meunier/lang/plt/collects/mred/mred.rkt: [traversing imports]
/home/meunier/lang/plt/collects/mred/main.rkt: [traversing imports]
/home/meunier/lang/plt/collects/scheme/gui/base.rkt: [traversing imports]
/home/meunier/lang/plt/collects/scheme/gui.rkt: [traversing imports]
/home/meunier/lang/plt/collects/racket/gui/init.rkt: [traversing imports]
/home/meunier/lang/plt/collects/scheme/gui/init.rkt: [traversing imports]

(the same error also shows up here and there during the setup phase of
the build)

I had to change a bunch of files in collects/racket/draw/unsafe to get
it to work (see the attached diff).  For reference, on OpenBSD the
library versions are currently as follows:


Just to make things more annoying, libcairo needs libpthread:

$ nm /usr/local/lib/libcairo.so.11.0 | egrep -i pthread
         U pthread_mutex_destroy
         U pthread_mutex_init
         U pthread_mutex_lock
         U pthread_mutex_unlock
         U pthread_mutexattr_destroy
         U pthread_mutexattr_init
         U pthread_mutexattr_settype

so I also had to change the define-runtime-lib macro from
collects/racket/draw/private/libs.rkt so that the unix case of the
macro accepts multiple libraries.  I'm not sure that's the best way to
go about adding libpthread though, and I'm definitely not sure that my
simple change to collects/racket/draw/unsafe/cairo.rkt to add
libpthread works on other platforms...

For reference, the current version of libpthread on OpenBSD is

With theses changes I was able to run drracket, except that:

- I got the following error at startup while the steep tool is being

Error invoking tool #<path:/home/meunier/lang/plt/collects/stepper>;("stepper+xml-tool.ss")
xml-box: bitmap scheme-box.jpg failed to load
 === context ===
/home/meunier/lang/plt/collects/drracket/private/tools-drs.rkt:96:0: invoke-drs-tool
/home/meunier/lang/plt/collects/drracket/drracket.rkt: [running body]

(I have no problem looking at the jpg file using xv or gimp)

- at startup I also got a good half dozen popup windows with error
  messages about preference files.  These were gray popup windows with
  a triangular red-white icon with a black question mark in it.  I
  tried to use the "copy message" mouse menu of these popup windows
  but it didn't work.  One popup window was different though (it
  seemed to use a text% editor rather than being just a basic frame
  with a gray background, and had a round red-white "no entry" icon)
  so I could copy from it the error message (which was similar to all
  the previous ones, and was also printed to the console):

copy-file: read or write failed; cannot copy: /home/meunier/.racket/racket-prefs.rktd to: /home/meunier/.racket/TMPPREF12938920161293892016827
 === context ===
/home/meunier/lang/plt/collects/framework/splash.rkt:172:0: close-splash
/home/meunier/lang/plt/collects/drracket/private/drracket-normal.rkt: [running body]
/home/meunier/lang/plt/collects/drracket/drracket.rkt: [running body]

internal error: wrong eventspace for constrained event handling

/home/meunier/lang/plt/collects/mred/private/wx/common/freeze.rkt:9:0 internal-error
/home/meunier/lang/plt/collects/mred/private/wx/common/freeze.rkt:36:0 constrained-reply
/home/meunier/lang/plt/collects/ffi/unsafe/try-atomic.rkt:32:0 call-as-nonatomic-retry-point

internal error: wrong eventspace for constrained event handling

/home/meunier/lang/plt/collects/mred/private/wx/common/freeze.rkt:9:0 internal-error
/home/meunier/lang/plt/collects/mred/private/wx/common/freeze.rkt:36:0 constrained-reply

- drracket then seemed to work fine, except that at the end I was left
  with the following files in $HOME/.racket:

$ ls -l .racket 
total 8
drwx------  3 meunier  users  512 Jan  1 22:05
-rw-------  1 meunier  users    0 Jan  1 23:25 TMPPREF12938919551293891955547
-rw-------  1 meunier  users    0 Jan  1 23:25 TMPPREF12938919551293891955634
-rw-------  1 meunier  users    0 Jan  1 23:26 TMPPREF12938919601293891960898
-rw-------  1 meunier  users    0 Jan  1 23:26 TMPPREF12938919621293891962122
-rw-------  1 meunier  users    0 Jan  1 23:26 TMPPREF12938919671293891967039
-rw-------  1 meunier  users    0 Jan  1 23:26 TMPPREF12938920161293892016827
-rw-------  1 meunier  users    0 Jan  1 23:28 TMPPREF12938920911293892091752
-rw-------  1 meunier  users  389 Jan  1 23:28 racket-prefs.rktd
$ cat .racket/racket-prefs.rktd 
 (plt:framework-pref:framework:exit-when-no-frames #t)
 (plt:framework-pref:drracket:unit-window-width 600)
 (plt:framework-pref:drracket:unit-window-max? #f)
 (plt:framework-pref:drracket:logging-size-percentage 1/2)
 (plt:framework-pref:drracket:unit-window-size-percentage 1/2)
 (plt:framework-pref:drracket:frame:initial-position #f)
 (plt:framework-pref:framework:verify-exit #t)


-------------- next part --------------
diff --git a/collects/mred/private/wx/gtk/utils.rkt b/collects/mred/private/wx/gtk/utils.rkt
index 069e4d4..7ce1cc8 100644
--- a/collects/mred/private/wx/gtk/utils.rkt
+++ b/collects/mred/private/wx/gtk/utils.rkt
@@ -56,19 +56,19 @@
      (ffi-lib "libgio-2.0-0")
      (ffi-lib "libgdk_pixbuf-2.0-0")
      (ffi-lib "libgdk-win32-2.0-0")]
-    [else (ffi-lib "libgdk-x11-2.0" '("0"))]))
+    [else (ffi-lib "libgdk-x11-2.0")]))
 (define gdk_pixbuf-lib 
   (case (system-type)
      (ffi-lib "libgdk_pixbuf-2.0-0")]
-     (ffi-lib "libgdk_pixbuf-2.0" '("0"))]
+     (ffi-lib "libgdk_pixbuf-2.0")]
     [else gdk-lib]))
 (define gtk-lib
   (case (system-type)
      (ffi-lib "libgtk-win32-2.0-0")]
-    [else (ffi-lib "libgtk-x11-2.0" '("0"))]))
+    [else (ffi-lib "libgtk-x11-2.0")]))
 (define-ffi-definer define-gtk gtk-lib)
 (define-ffi-definer define-gdk gdk-lib)
diff --git a/collects/racket/draw/private/libs.rkt b/collects/racket/draw/private/libs.rkt
index 29adf9d..05becf6 100644
--- a/collects/racket/draw/private/libs.rkt
+++ b/collects/racket/draw/private/libs.rkt
@@ -36,7 +36,7 @@
              (for/fold ([v #f]) ([lib (in-list libs)])
                (ffi-lib lib)))))]
     [(_ lib-id
-        [(unix) unix-lib]
+        [(unix) (ffi-lib unix-lib) ...]
         [(macosx) (ffi-lib mac-lib) ...]
         [(win32) (ffi-lib win32-lib) ...]
         [(win64) (ffi-lib win64-lib) ...])
@@ -44,16 +44,14 @@
        (define-runtime-path-list libs
          (case (system-type)
            [(macosx) '((so mac-lib) ...)]
-           [(unix) null]
+           [(unix) `((so unix-lib) ...)]
             (if win64?
                 `((so win64-lib) ...)
                 `((so win32-lib) ...))]))
        (define lib-id
-         (if (null? libs)
-             unix-lib
-             (for/fold ([v #f]) ([lib (in-list libs)])
-               (ffi-lib lib)))))]))
+         (for/fold ([v #f]) ([lib (in-list libs)])
+           (ffi-lib lib))))]))
diff --git a/collects/racket/draw/unsafe/cairo.rkt b/collects/racket/draw/unsafe/cairo.rkt
index 4452bd5..149add0 100644
--- a/collects/racket/draw/unsafe/cairo.rkt
+++ b/collects/racket/draw/unsafe/cairo.rkt
@@ -7,7 +7,7 @@
 (define-runtime-lib cairo-lib
-  [(unix) (ffi-lib "libcairo" '("2"))]
+  [(unix) (ffi-lib "libpthread") (ffi-lib "libcairo")]
    (ffi-lib "libpixman-1.0.dylib")
    (ffi-lib "libpng14.14.dylib")
diff --git a/collects/racket/draw/unsafe/glib.rkt b/collects/racket/draw/unsafe/glib.rkt
index f38bdf5..91f0bd8 100644
--- a/collects/racket/draw/unsafe/glib.rkt
+++ b/collects/racket/draw/unsafe/glib.rkt
@@ -9,12 +9,12 @@
 (define-runtime-lib glib-lib 
-  [(unix) (ffi-lib "libglib-2.0" '("0"))]
+  [(unix) (ffi-lib "libglib-2.0")]
   [(macosx) (ffi-lib "libglib-2.0.0")]
   [(windows) (ffi-lib "libglib-2.0-0.dll")])
 (define-runtime-lib gmodule-lib 
-  [(unix) (ffi-lib "libgmodule-2.0" '("0"))]
+  [(unix) (ffi-lib "libgmodule-2.0")]
    (ffi-lib "libgmodule-2.0.0.dylib")]
@@ -24,7 +24,7 @@
    (ffi-lib "libgmodule-2.0-0.dll")])
 (define-runtime-lib gobj-lib 
-  [(unix) (ffi-lib "libgobject-2.0" '("0"))]
+  [(unix) (ffi-lib "libgobject-2.0")]
   [(macosx) (ffi-lib "libgobject-2.0.0")]
   [(windows) (ffi-lib "libgobject-2.0-0.dll")])
diff --git a/collects/racket/draw/unsafe/jpeg.rkt b/collects/racket/draw/unsafe/jpeg.rkt
index 3b184e4..38ac07e 100644
--- a/collects/racket/draw/unsafe/jpeg.rkt
+++ b/collects/racket/draw/unsafe/jpeg.rkt
@@ -9,7 +9,7 @@
 (define-runtime-lib jpeg-lib 
-  [(unix) (ffi-lib "libjpeg" '("62" ""))]
+  [(unix) (ffi-lib "libjpeg")]
    ;; for PPC, it's actually version 8!
    (ffi-lib "libjpeg.62.dylib")]
@@ -21,7 +21,10 @@
                             (path->string (system-library-subpath #f)))
-    [(unix) 62]
+    [(unix) (if (string=? "i386-openbsd"
+                          (path->string (system-library-subpath #f)))
+                64
+                62)]
     [(windows) 70]))
 (define-ffi-definer define-jpeg jpeg-lib
diff --git a/collects/racket/draw/unsafe/pango.rkt b/collects/racket/draw/unsafe/pango.rkt
index 75ff685..4e76745 100644
--- a/collects/racket/draw/unsafe/pango.rkt
+++ b/collects/racket/draw/unsafe/pango.rkt
@@ -10,7 +10,7 @@
 (define-runtime-lib pango-lib 
-  [(unix) (ffi-lib "libpango-1.0" '("0"))]
+  [(unix) (ffi-lib "libpango-1.0")]
    (ffi-lib "libintl.8.dylib")
    (ffi-lib "libpango-1.0.0.dylib")]
@@ -24,7 +24,7 @@
    (ffi-lib "libpangowin32-1.0-0.dll")])
 (define-runtime-lib pangocairo-lib 
-  [(unix) (ffi-lib "libpangocairo-1.0" '("0"))]
+  [(unix) (ffi-lib "libpangocairo-1.0")]
    (ffi-lib "libpangocairo-1.0.0.dylib")]
diff --git a/collects/racket/draw/unsafe/png.rkt b/collects/racket/draw/unsafe/png.rkt
index 8d28e6d..5c8fcf6 100644
--- a/collects/racket/draw/unsafe/png.rkt
+++ b/collects/racket/draw/unsafe/png.rkt
@@ -12,6 +12,7 @@
    (case (string->symbol (path->string (system-library-subpath #f)))
      [(i386-freebsd) (ffi-lib "libpng")]
+     [(i386-openbsd) (ffi-lib "libpng")]
       (ffi-lib "libpng12" '("0" ""))])]
   [(macosx) (ffi-lib "libpng14.14.dylib")]

Posted on the dev mailing list.