[gambit-list] static lib question

Marc Feeley feeley at iro.umontreal.ca
Thu Feb 2 12:03:07 EST 2012


On 2012-02-02, at 10:45 AM, REPLeffect wrote:

> Let's say I have the following set of files ...
> 
>  f1a.scm and f1b.c
> 
>  f2a.scm and f2b.c
> 
>  f3.scm
> 
>  File f1a.scm contains scheme procedures that call C functions in f1b.c.
> 
>  File f2a.scm contains scheme procedures that call C funcitons in f2b.c.
> 
>  I would like to build a static library f1.a from f1a.scm and f1b.c,
> 
> and likewise I wish to build a static library f2.a from f2a.scm and f2b.c.
> 
> Finally, assume f3.scm will call scheme procedures from both the f1.a and
> f2.a static libraries.
> 
> What are the appropriate commands for:
> 
> 1) building the f1.a and f2.a static libraries
> 
> 2) compiling and linking f3.scm with *both* of those static libraries
> at the same time.
> 
> (I'm looking for an example using gcc on a Linux platform.)

Here are the steps.  The gist is that you have to create flat link files for each library, and then create an incremental link file for the final executable from the library link files.

gsc -c -o f1a.c f1a.scm
gsc -obj -o f1a.o f1a.c
gcc -c -o f1b.o f1b.c
gsc -link -flat -o f1_.c f1a.c f1b.c
*** WARNING -- "display" is not defined,
***            referenced in: ("f1a.c")
gsc -obj -o f1_.o -cc-options "-D___LIBRARY" f1_.c
ar -rc f1.a f1a.o f1b.o f1_.o
gsc -c -o f2a.c f2a.scm
gsc -obj -o f2a.o f2a.c
gcc -c -o f2b.o f2b.c
gsc -link -flat -o f2_.c f2a.c f2b.c
*** WARNING -- "display" is not defined,
***            referenced in: ("f2a.c")
gsc -obj -o f2_.o -cc-options "-D___LIBRARY" f2_.c
ar -rc f2.a f2a.o f2b.o f2_.o
gsc -c -o f3.c f3.scm
gsc -obj -o f3.o f3.c
gsc -link -o f3_.c f1_.c f2_.c f3.c
gsc -obj -o f3_.o f3_.c
gsc -exe -o f3.exe -ld-options "f1.a f2.a" f3_.o f3.o

I have included a tar file which contains an example with makefile.  It has been tested on Linux and Mac OS X.

Marc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: example-make-libs.tar.gz
Type: application/x-gzip
Size: 700 bytes
Desc: not available
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20120202/3957a29f/attachment.bin>


More information about the Gambit-list mailing list