unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* SWIG 1.3, guile 1.4, and compiled module loading
@ 2002-03-18 23:06 Brett Viren
  2002-03-18 23:41 ` Thien-Thi Nguyen
  0 siblings, 1 reply; 4+ messages in thread
From: Brett Viren @ 2002-03-18 23:06 UTC (permalink / raw)


Hi all,

I am writing a small SWIG wrapper around a library.  This may not be
pertinent, but I mention it for completeness.  I am trying to
understand how to make things work so that I can do:

shell> guile
guile> (use-modules (mydir mymod))

Currently I run SWIG like:

swig-1.3 -guile -scmstub mymod.scm -Linkage passive -package mydir -module mymod mymod.i

Which produces mymod.scm and mymod_wrap.[ch] which is compiled into a
libmymod.so.  The .scm and the .so then get placed in a mydir/
directory which is in my %load-path.

In mymod.scm I have

(define-module (mydir mymod))
(define my-so (dynamic-link "/full/path/to/mydir/libmymod.so"))
(dynamic-call "scm_init_mydir_mymod_module" my-so)
(export sym1 sym2 sym3)

Everything after define-module and before export I have control over.

This gets executed when I do (use-modules (mydir mymod)) but my
problem is I can't figure out how to do the dynamic-link call in any
way except giving the full path to the library.  Is there some way to
fix this so the installation of mydir/ is more portable?

Thanks,
-Brett.

_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Re: SWIG 1.3, guile 1.4, and compiled module loading
  2002-03-18 23:06 SWIG 1.3, guile 1.4, and compiled module loading Brett Viren
@ 2002-03-18 23:41 ` Thien-Thi Nguyen
  2002-03-19 14:12   ` Brett Viren
  0 siblings, 1 reply; 4+ messages in thread
From: Thien-Thi Nguyen @ 2002-03-18 23:41 UTC (permalink / raw)
  Cc: guile-user

   From: Brett Viren <bv@bnl.gov>
   Date: Mon, 18 Mar 2002 18:06:26 -0500

   Which produces mymod.scm and mymod_wrap.[ch] which is compiled into a
   libmymod.so.  The .scm and the .so then get placed in a mydir/
   directory which is in my %load-path.

how is this compilation done (e.g., w/ libtool)?

   This gets executed when I do (use-modules (mydir mymod)) but my
   problem is I can't figure out how to do the dynamic-link call in any
   way except giving the full path to the library.  Is there some way to
   fix this so the installation of mydir/ is more portable?

guile 1.4 libguile embeds libltdl, which is responsible for abstracting
shared object library access and initialization.  libltdl is sensitive
to env var LTDL_LIBRARY_PATH.

i cannot remember if swig 1.3 uses libltdl (shame on me for slacking off
on swig, i know).  your system's ld.so might respond to LD_LIBRARY_PATH.

thi

_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Re: SWIG 1.3, guile 1.4, and compiled module loading
  2002-03-18 23:41 ` Thien-Thi Nguyen
@ 2002-03-19 14:12   ` Brett Viren
  2002-04-03  6:52     ` Thien-Thi Nguyen
  0 siblings, 1 reply; 4+ messages in thread
From: Brett Viren @ 2002-03-19 14:12 UTC (permalink / raw)
  Cc: guile-user

Thien-Thi Nguyen writes:
 > how is this compilation done (e.g., w/ libtool)?

Just by hand:

gcc -fPIC -c mymod_wrap.c -o mymod_wrap.o
gcc -shared -o libmymod.so mymod_wrap.o -lmywrappedlib

 > guile 1.4 libguile embeds libltdl, which is responsible for abstracting
 > shared object library access and initialization.  libltdl is sensitive
 > to env var LTDL_LIBRARY_PATH.
 > 
 > i cannot remember if swig 1.3 uses libltdl (shame on me for slacking off
 > on swig, i know).  your system's ld.so might respond to LD_LIBRARY_PATH.

On:

http://www.math.uni-magdeburg.de/~mkoeppe/guile/swig-guile.html

it talks about using -Linkage ltdlmod but says this is deprecated.
This was what in fact what I used a long while ago in a previous
(failed do to lack of time) effort.  There is also "native guile
module linkage" but that requires guile 1.5.  This looks like it works
much easier, but I would like to stick with guile 1.4 for now (at lest
until Debian distributes 1.5), so "passive" linkage looked like the
best compromise. (BTW, kudos to you, Matthias and other SWIG Guile
hackers for so many choices!)

I just tried this method.  With it I must write my SWIG .i file a
little differently to explicitly add define-module and export, but in
the end the result are the same.  When I set LTDL_LIBRARY_PATH it
looks for the library in there, not in the mydir/.  If I use
(dynamic-link "mydir/libmymod.so") it also fails.

Do I need to use libtool for ltdlmod linkage?  If so, anything special
I should know, or should I just hit the info pages?

-Brett.


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Re: SWIG 1.3, guile 1.4, and compiled module loading
  2002-03-19 14:12   ` Brett Viren
@ 2002-04-03  6:52     ` Thien-Thi Nguyen
  0 siblings, 0 replies; 4+ messages in thread
From: Thien-Thi Nguyen @ 2002-04-03  6:52 UTC (permalink / raw)
  Cc: guile-user

   From: Brett Viren <bv@bnl.gov>
   Date: Tue, 19 Mar 2002 09:12:57 -0500

   Do I need to use libtool for ltdlmod linkage?  If so, anything
   special I should know, or should I just hit the info pages?

i'm guessing Yes, but unfortunately don't know for sure (when i was
working on swig, it was for python not guile!).
							  
if (when) you figure this stuff out, please consider writing a short
HOWTO -- i'd be glad to post that under http://www.glug.org/docbits/
and work it back into the swig documentation.

thi

_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

end of thread, other threads:[~2002-04-03  6:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-18 23:06 SWIG 1.3, guile 1.4, and compiled module loading Brett Viren
2002-03-18 23:41 ` Thien-Thi Nguyen
2002-03-19 14:12   ` Brett Viren
2002-04-03  6:52     ` Thien-Thi Nguyen

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