Using Gambit with External Libraries

From Gambit wiki

(New page: == Using gsc to compile and link a dynamically loadable object file that uses external libraries == Here is an example of building a dynamically loadable Gambit object file that uses [htt...)

Finally, recall from the the [http://www.iro.umontreal.ca/~gambit/doc/gambit-c.html#SEC21 Gambit manual] that anything you can do with gsc on the command line you can do with one of the gsc-specific scheme procedures <tt>compile-file</tt>, <tt>compile-file-to-c</tt>, <tt>link-incremental</tt>, or <tt>link-flat</tt>. Thus, one could build <tt>fftbasic.o1</tt> by

You need the --enable-shared option because shared Gambit modules must be linked to shared external libraries. I set the --prefix to install the final FFTW libraries and header files in my home directory.

The file fftbasics.scm provides the basic interface between the Scheme code and FFTW; it is as follows:

The first option (-I/export/users/lucier/local/fftw-2.1.5/include) tells gcc where to find the header file fftw.h at compile time. The second option (-L/export/users/lucier/local/fftw-2.1.5/lib/) tells the linker where to find the FFTW library (-lfftw) at link time (i.e., when building the file fftwbasic.o1 from fftwbasic.o), and the third option (-Wl,-rpath,/export/users/lucier/local/fftw-2.1.5/lib/) tells the dynamic loader ldd where to find the FFTW library when fftwbasic.o1 is loaded into gsc.

Finally, recall from the the Gambit manual that anything you can do with gsc on the command line you can do with one of the gsc-specific scheme procedures compile-file, compile-file-to-c, link-incremental, or link-flat. Thus, one could build fftbasic.o1 by