public inbox for guile-gtk@sourceware.org
 help / color / mirror / Atom feed
* guile-gtk without dlopen (HP-UX)
@ 1999-11-07 15:47 Stephen Tell
  1999-11-08 13:27 ` Marius Vollmer
  1999-11-18 13:05 ` Converting GdkEvent from C to Guile Stephen Tell
  0 siblings, 2 replies; 7+ messages in thread
From: Stephen Tell @ 1999-11-07 15:47 UTC (permalink / raw)
  To: Guile-Gtk List

Hello,

I'm trying to extend a C/Gtk+ program that I've written (gwave -
http://www.cs.unc.edu/~tell/gwave/index.html ) to move parts of
its GUI into guile-gtk, leaving the core in C.

Things are fine on linux, but I'm having a great deal of trouble with
libraries and linking on HP-UX 10.20.  HP-UX is a unix with wierd dynamic
linking; using a function called shl_load() instead of dlopen(), so of
course libguiledlopenhelper is going to lose.

Pure-guile programs (like test-gtk.scm) fail if run  with "guile
-s" but do work fine if run with "guile-gtk -s"; the error message in the
former case is:

;;; WARNING (Cannot find library libguilegtk-1.2)
ERROR: In procedure dynamic-link:
ERROR: dynamic linking failed

So given all this, what is the right way to link a program that wants to
use Gtk+ both from C and guile-gtk, but on which dynamic loading of the
gtk module fails? 

What works on Linux is to essentialy add "-lguilegtk-1.2" to the link line
(after checking for it with configure), but that produces the same
sort of failure on HP-UX.

I also tried using "build-guile-gtk libs" in configure, in the same manner
as the example configure.in does for examples/guile-foo, with the same
result.  There's no explanation of how that example is supposed to be run,
so I'm not sure if it is working for me or or not.  I'm not trying to wrap
any new widgets, so that example doesn't really apply anyway.

So, has anyone made guile-gtk work on HP-UX, or anyplace where
dlopenhelper and dynlink.scm don't work, or am I blazing new territory
here?    Could the dlopenhelper library be made to fall back on whatever
guile uses when HAVE_DLOPEN is not defined?

details:

HP-UX 10.20
gcc-2.7.2.2
guile-1.3.4
gtk+ and glib 1.2.6
guile-gtk-0.17

Thanks!
Steve

p.s. I've placed a rough preliminary snapshot of the guile-ified version
in http://www.cs.unc.edu/~tell/dist/gwave-guile-19991107.tar.gz , just in
case anyone really wants to look at it.


-- 
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: guile-gtk without dlopen (HP-UX)
  1999-11-07 15:47 guile-gtk without dlopen (HP-UX) Stephen Tell
@ 1999-11-08 13:27 ` Marius Vollmer
  1999-11-08 19:08   ` Stephen Tell
  1999-11-18 13:05 ` Converting GdkEvent from C to Guile Stephen Tell
  1 sibling, 1 reply; 7+ messages in thread
From: Marius Vollmer @ 1999-11-08 13:27 UTC (permalink / raw)
  To: Stephen Tell; +Cc: Guile-Gtk List

Stephen Tell <tell@cs.unc.edu> writes:

> Things are fine on linux, but I'm having a great deal of trouble with
> libraries and linking on HP-UX 10.20.  HP-UX is a unix with wierd dynamic
> linking; using a function called shl_load() instead of dlopen(), so of
> course libguiledlopenhelper is going to lose.

Yes, dynamic linking is weird with guile-gtk in general, and I'm sorry
you have to suffer.

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.

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.

> guile-1.3.4

This is recent enough.

- Marius

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: guile-gtk without dlopen (HP-UX)
  1999-11-08 13:27 ` Marius Vollmer
@ 1999-11-08 19:08   ` Stephen Tell
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Tell @ 1999-11-08 19:08 UTC (permalink / raw)
  To: Marius Vollmer; +Cc: Guile-Gtk List

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,
removing all of the 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 

 
> 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.
> 
> > guile-1.3.4
> 
> This is recent enough.
> 
> - Marius
> 

-- 
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Converting GdkEvent from C to Guile
  1999-11-07 15:47 guile-gtk without dlopen (HP-UX) Stephen Tell
  1999-11-08 13:27 ` Marius Vollmer
@ 1999-11-18 13:05 ` Stephen Tell
  1999-11-18 15:14   ` Marius Vollmer
  1 sibling, 1 reply; 7+ messages in thread
From: Stephen Tell @ 1999-11-18 13:05 UTC (permalink / raw)
  To: Guile-Gtk List

In guile-gtk 0.17, how do I convert a pointer to a GdkEvent (or
GdkEventButton) to an SCM so it can be passed to a guile callback?

With a little rummaging around in the source, I found sgtk_wrap_gtkobj()
which does the appropriate magic for Gtk objects, but (perhaps not too
surprisingly) it coredumps when passed a (GdkEventButton *).  There must
be an appropriate function in there someplace.

Thanks,
Steve

-- 
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Converting GdkEvent from C to Guile
  1999-11-18 13:05 ` Converting GdkEvent from C to Guile Stephen Tell
@ 1999-11-18 15:14   ` Marius Vollmer
  1999-11-18 15:50     ` Stephen Tell
  0 siblings, 1 reply; 7+ messages in thread
From: Marius Vollmer @ 1999-11-18 15:14 UTC (permalink / raw)
  To: Stephen Tell; +Cc: Guile-Gtk List

Stephen Tell <tell@cs.unc.edu> writes:

> In guile-gtk 0.17, how do I convert a pointer to a GdkEvent (or
> GdkEventButton) to an SCM so it can be passed to a guile callback?

You use

    GdkEvent *ev;
    SCM val;

    extern sgtk_boxed_info sgtk_gdk_event_info;
    val = sgtk_boxed2scm (ev, &sgtk_gdk_event_info, copyp);

COPYP determines whether sgtk_boxed2scm will amke a copy of EV or not.
If you want guile-gtk to become owner of the GdkEvent structure
pointed to by EV (i.e guile-gtk can free it whenever it likes, using
gdk_event_free) you would use FALSE for COPYP.  When you want to stay
the owner of EV, say TRUE.  You should only say FALSE when EV is the
result of gdk_event_copy, as a rule.
 
- Marius

-- 
(let ((p #(78 91 29 77 90 51 71 91 86 24 54 55 119 16 104 62 42 58 121 80 10
124 48 102 79 22 12 116 27 34 37 100 16 83 115 40 126)))  (define (x n)  (do
((i 0 (1+ i))  (s 0 (+ s (* (vector-ref p i)  (expt n i)))))  ((= i 37) s)))
(do ((i 1 (1+ i))) ((= i 38)) (display (integer->char (modulo (x i) 127)))))

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Converting GdkEvent from C to Guile
  1999-11-18 15:14   ` Marius Vollmer
@ 1999-11-18 15:50     ` Stephen Tell
  1999-11-19 13:51       ` Marius Vollmer
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Tell @ 1999-11-18 15:50 UTC (permalink / raw)
  To: Marius Vollmer; +Cc: Guile-Gtk List

On 18 Nov 1999, Marius Vollmer wrote:

>     GdkEvent *ev;
>     SCM val;
>     extern sgtk_boxed_info sgtk_gdk_event_info;
>     val = sgtk_boxed2scm (ev, &sgtk_gdk_event_info, copyp);

Thanks, this works.
 
> COPYP determines whether sgtk_boxed2scm will amke a copy of EV or not.
> If you want guile-gtk to become owner of the GdkEvent structure
> pointed to by EV (i.e guile-gtk can free it whenever it likes, using
> gdk_event_free) you would use FALSE for COPYP.  When you want to stay
> the owner of EV, say TRUE.  You should only say FALSE when EV is the
> result of gdk_event_copy, as a rule.
  
Just to make sure I understand Gdk's (undocumented) rules: when I get the
GdkEvent as an argument to a handler set with gtk_signal_connect(),
Gdk/Gtk is going to free the event when the handler returns.  So if I let
it escape to the guile-gtk world, I set COPYP to TRUE, so guile frees its
copy when it is done with it.

(Actually, I'd rather not pass the event up at all, but if the guile side
wants to pop up a menu on the event, gtk-menu-popup needs the event's time
for some reason.)

Steve

-- 
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Converting GdkEvent from C to Guile
  1999-11-18 15:50     ` Stephen Tell
@ 1999-11-19 13:51       ` Marius Vollmer
  0 siblings, 0 replies; 7+ messages in thread
From: Marius Vollmer @ 1999-11-19 13:51 UTC (permalink / raw)
  To: Stephen Tell; +Cc: Guile-Gtk List

Stephen Tell <tell@cs.unc.edu> writes:

> Just to make sure I understand Gdk's (undocumented) rules: when I get the
> GdkEvent as an argument to a handler set with gtk_signal_connect(),
> Gdk/Gtk is going to free the event when the handler returns.

Yes, more or less.  It just reuses the memory for the next event, in
the normal case.

> So if I let it escape to the guile-gtk world, I set COPYP to TRUE,
> so guile frees its copy when it is done with it.

Correct.
 
- Marius

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1999-11-19 13:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-07 15:47 guile-gtk without dlopen (HP-UX) Stephen Tell
1999-11-08 13:27 ` Marius Vollmer
1999-11-08 19:08   ` Stephen Tell
1999-11-18 13:05 ` Converting GdkEvent from C to Guile Stephen Tell
1999-11-18 15:14   ` Marius Vollmer
1999-11-18 15:50     ` Stephen Tell
1999-11-19 13:51       ` Marius Vollmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).