[gambit-list] OS X 10.6 "Building Loadable Library" example
Marc Feeley
feeley at iro.umontreal.ca
Thu Dec 30 19:40:35 EST 2010
On 2010-12-29, at 2:35 PM, David Dreisigmeyer wrote:
> Hi,
>
> I've been trying the "Building Loadable Library" m1/m2/m3 example (pg
> 16 of pdf manual). I'm getting the following error:
>
> $ gcc -bundle m1.o m2.o m3.o foo.o1.o -o foo.o1
> -L/opt/local/lib/gambit-c -lgambc -I/opt/local/include
> ld: duplicate symbol ____G_cons in
> /opt/local/lib/gambit-c/libgambc.a(_gambc.o) and foo.o1.o
> collect2: ld returned 1 exit status
>
Hmmm... thanks for catching that... it is a bug in the documentation (now fixed). When compiling a dynamically loadable library, the flag -D___DYNAMIC must be given to the C compiler (when generating the .o files) so that it does not compile the "main" function in foo.o1.c (this is actually explained a few lines above the example in the documentation). So the correct sequence is:
$ gsc -link -flat -o foo.o1.c m2 m3 > /dev/null
$ gsc -cc-options "-D___DYNAMIC" -obj m1.c m2.c m3.c foo.o1.c
$ gcc -bundle m1.o m2.o m3.o foo.o1.o -o foo.o1
$ gsi foo.o1
> Also, after this works, can I do something like the following:
>
> $gsi
>> (load "foo.o1")
>> (map twice '(5))
Yes...
$ gsi
Gambit v4.6.0
> (load "foo.o1")
((2 . 2) (4 . 4) (8 . 8) (16 . 16))
"/Users/feeley/foo.o1"
> (map twice '(5))
((5 . 5))
Marc
More information about the Gambit-list
mailing list