[gambit-list] OS X 10.6 "Building Loadable Library" example

David Dreisigmeyer dwdreisigmeyer at gmail.com
Fri Dec 31 00:14:21 EST 2010


Thanks Marc, that worked.  This was a little confusing to me (pg 11 of
the pdf manual):

"The ‘-cc-options’ option is only meaningful when a dynamically
loadable object file
is being generated (neither the ‘-c’ or ‘-link’ options are used)."

On Thu, Dec 30, 2010 at 7:40 PM, Marc Feeley <feeley at iro.umontreal.ca> wrote:
>
> 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