This is the mail archive of the guile@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: HELP: Modules and dlopen


Ian Grant <I.A.N.Grant@damtp.cam.ac.uk> writes:

> I have written half a dozen glue procedures and a couple of smobs that
> implement a Postgres interface for guile. I based them on Russ's sybase
> interface and Jim's data-rep document. The interface is pretty-much a
> one-one mapping from the Postgres client library to guile procedures. 

Great!  I've wished for such an interface for long.

> >From discussions on this list it sounds like there is support for this in
> guile, though I didn't understand them. Is there any documentation for
> this yet? What I'd really like would be to see Jim's image-type smob
> example written this way. Can someone do this for me? (It would be useful
> for many others too I'm sure. Consider it a beta-test of the
> documentation.)

It's very simple.  (BTW, there's some documentation in boot-9.scm.)

Let's say your init function is named scm_init_postgres.

Then write a new function:

void
scm_init_postgres_gpostgres_module ()
{
  scm_register_module_xxx ("postgres gpostgres", scm_init_postgres);
}

Compile everything into a shared library (libgpostgres.so) and install.
Put links from /usr/local/share/guile/postgres/libgpostgres.la and
/usr/local/share/guile/postgres/libgpostgres.so.1 to
/usr/local/lib/libgpostgres.la and /usr/local/lib/libgpostgres.so.1.

(Of course you may have to replace /usr/local with some other prefix.)

Then you should be able to load the object code with

(use-modules (postgres gpostgres))

If you have scheme code as well you could put it into
/usr/local/share/guile/postgres/postgres.scm and start the file with

(define-module (postgres postgres)
  :use-module (postgres gpostgres))

/mdj