[gambit-list] loadable libraries

Lang Martin lang-gb at coptix.com
Wed Sep 27 12:32:51 EDT 2006


I'm working my way through my first FFI, and I'm kind of stuck.
Currently, I can compile my library with this:


gsc -o a.out.c -cc-options "-Idjbdns-1.05 -Ldjbdns-1.05" djbdns > /dev/null

gcc -o a.out -Idjbdns-1.05 -Ldjbdns-1.05 djbdns.c a.out.c
djbdns-1.05/iopause.o djbdns-1.05/dns.a djbdns-1.05/env.a
djbdns-1.05/libtai.a djbdns-1.05/alloc.a djbdns-1.05/buffer.a
djbdns-1.05/unix.a djbdns-1.05/byte.a
-lgambc


And, when I run ./a.out google.com, it spits out the list of google's
MX records as I had hoped.

However, when I attept to produce a (load)-able library, it fails.


gsc -o djbdns.o1.c
-flat
-cc-options "-Idjbdns-1.05 -Ldjbdns-1.05" djbdns > /dev/null

gcc -o djbdns.o1
-bundle -bundle_loader /usr/local/bin/gsi -D___DYNAMIC
-Idjbdns-1.05 -Ldjbdns-1.05 djbdns.c djbdns.o1.c
djbdns-1.05/iopause.o djbdns-1.05/dns.a djbdns-1.05/env.a
djbdns-1.05/libtai.a djbdns-1.05/alloc.a djbdns-1.05/buffer.a
djbdns-1.05/unix.a djbdns-1.05/byte.a


I've organized those with the changed options isolated on the second
line.

running with gsi, I get this:

$ gsi djbdns.o1
debug: dnsmx: stralloc is about to go on djbdns.o1
zsh: bus error  gsi djbdns.o1

That debug line was generated by a printf line inside the C section of
the code -- it occurs right before the first call that allocates
memory. This call, stralloc_cats, is inside one of the linked object
libs (alloc.a).

I'm kind of out of my depth here, although I do think I generally get
the hang of the process now. Sorry if this is too much detail, I
didn't want to omit anything significant.

I'm working on my lovely new macbook, where
$ uname -a
Darwin lang.coptix.lan 8.7.1 Darwin Kernel Version 8.7.1: Wed Jun  7
16:19:56 PDT 2006; root:xnu-792.9.72.obj~2/RELEASE_I386 i386 i386



More information about the Gambit-list mailing list