This is the mail archive of the guile-gtk@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: guile-gtk without dlopen (HP-UX) (fwd)



(sorry -  a previous fragment of this message got away from me
too soon.)

On 8 Nov 1999, Marius Vollmer wrote:

> However, in recent releases of Guile, dynamic-link uses RTLD_GLOBAL by
> default and thus libguiledlopenhelper is not needed at all (on dlopen
> platforms).  You might have to check the HPUX support of Guile if it
> behaves correctly, tho.  You could try to hack gtk/dynlink.scm so that
> it doesn't use the %sgtk-* functions at all.  If this doesn't work, we
> can then see how you can get by without dynamic linking.

I got my program running by hacking a copy of gtk/dynlink.scm,
to remove all of the sgtk/dlopen stuff, and changing 
merge-compiled-code to call the procedures try-using-libtool-name
and link-dynamic-module (found in boot-9.scm) instead of
dlopen-libtool-library and %sgtk-dlinit.

It looked like I wanted to use find-and-link-dynamic-module,
but it doesn't let the caller specify the init function and also looks in
searches for libtool .la files in %load-path.    Instead of adapting one
of the path-searching functions, I just coded in the right directory name
for this test.  FWIW, the hacked dynlink.scm is below.

Looking in %load-path seems pretty bogus, because by default it seems to
contain only directories under $PREFIX/share.  Either I must have to
manually add the right architecture-specific directories to
GUILE_LOAD_PATH, or it should really be looking in the shared library
path.

Somthing isn't quite right about this yet, because this doesn't work with
standalone guile-gtk applications.  I can get "guile-gtk -s
hello-world.scm" to work with my hacked dynlink.scm, but not "guile -s"

$ guile -s ./hello-world.scm
in sgt's hacked dynlink.scm
module-prefix is gtk-1.2
new merge-compiled-code guilegtk-1.2 sgtk_init_gtk_gtk_glue
ERROR: In procedure dynamic-call in expression (dynamic-call initname dynobj):
ERROR: undefined function

I think this may mean that I'm not really managing to load the dynamic
library, but that I can use it if it is already linked in. Part of my
difficulty modifying dynlink.scm is that I don't really understand what
the rest of merge-compiled-code is trying to do - possibly fiddling with
the module system to avoid loading anything twice?  (Still anxiously
waiting some real guile documentation here.)

And while I'm getting tracebacks on errors within my program, I can't
for the life of me get tracebacks from hello-world.scm, despite sprinkling
around the usual incantation: 
	(debug-enable 'backtrace) (read-enable 'positions)


Sorry for rambling on...  I've got a lashup that seems to work, but
haven't helped advance things much in general. This may be good enough for
me for a while.  I'll also try sprinkling (display) statements around the
dynamic-linking stuff in boot-9.scm.


> For the real fix, I think we need to have configure find out whether
> libguiledlopenhelper is needed or not because people might still be
> using old versions of Guile.

But we might as well skip libguiledlopenhelper if HAVE_DLOPEN is false,
since it isn't going to work anyway.

Thanks for the suggestions!
Steve

P.S.  The name of the environment variable containing the shared library
path varies, by the way: "libtool --config | grep shlibpath_var" will
yield LD_LIBRARY_PATH on linux and solaris, SHLIB_PATH on HP-UX.



-- 
Steve Tell | tell@cs.unc.edu | http://www.cs.unc.edu/~tell | KF4ZPF
Research Associate, Microelectronic Systems Laboratory
Computer Science Department, UNC@Chapel Hill.   W:919-962-1845

;; -*- scheme -*-

(display "in sgt's hacked dynlink.scm\n")

(debug-enable 'debug)
(debug-enable 'backtrace)
(read-enable 'positions)

(define-module (gtk dynlink)
  :use-module (gtk config)
  :use-module (ice-9 regex)
  :use-module (ice-9 debug)
)

(define (update-registered-modules)
  (set! registered-modules 
	(append! (convert-c-registered-modules #f)
		 registered-modules)))
;
; my attempt at using guile's own dynamic-libary stuff from boot-9.
;
(define-public (merge-compiled-code init-func libname)
  (let* ((module (current-module))
	 (interface (module-public-interface module))
	 (libnamenolib (make-shared-substring libname 3)))
    ;; make the new primitives visible from within the current module.
    (module-use! module interface) ; XXX - is this safe?
    (save-module-excursion
     (lambda ()
       (update-registered-modules)
       (set-current-module interface)

       (display "new merge-compiled-code ")
       (display libnamenolib)(display " ")(display init-func)(newline)

       (let* ((modname (list 'gtk '%static-initfuncs%
			     (string->symbol init-func)))
	      (modinfo (or-map (lambda (modinfo)
				 (if (equal? (car modinfo) modname)
				     modinfo
				     #f))
			       registered-modules))
	      (init-func (if modinfo (cadr modinfo) init-func))

	      (sharlib-full (try-using-libtool-name 
			     "/usr/local/contrib/moderated/lib" libname))

;	      (lib       (if modinfo (caddr modinfo)
;			     (or (link-dynamic-module sharlib-full init-func)
;				 (error "can't open library" libname)))))

; link-dynamic-module never returns anything.
	      )
	 (display "sharlibfull is ") (display sharlib-full)(newline)
	 (link-dynamic-module sharlib-full init-func)

;	 (display "lib is ") (display lib)(newline)
	 (display "modinfo is ") (display modinfo)(newline)

)))))

(define default-module-prefix 
  (string->symbol (string-append "gtk-" gtkconf-version)))
(define module-prefix #f)

(define-public (gtk-version-set prefix)
  (if (and module-prefix (not (eq? prefix module-prefix)))
      (error "Can't mix" module-prefix 'and prefix)
      (set! module-prefix prefix)))

(define-public (gtk-version-alias suffix)
  (if (not module-prefix)
      (set! module-prefix default-module-prefix))
;  (display "module-prefix is ")(display module-prefix)(newline)
  (let* ((mod-name (list module-prefix suffix))
	 (mod-iface (resolve-interface mod-name)))
    (or mod-iface
	(error "no such module" mod-name))
    (set-module-public-interface! (current-module) mod-iface)))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]