To build a library you proceed more or less the same way as with standalone executables. There are two different functions depending on whether you need to build static or shared libraries.
— Function:c:build-static-library
{
library-name
&key
lisp-files
prologue-code
epilogue-code
init-name
}
— Function:c:build-shared-library
{
library-name
&key
lisp-files
prologue-code
epilogue-code
ld-flags
init-name
}
This function builds a library file up from the object files listed in
lisp-files
. Each of the arguments tolisp-file
must name a single object file produced withcompile-file
.
library-name
is the physical pathname corresponding to the library. The value oflibrary-name
must follow some system-specific conventions. To make your program portable,library-name
should be built using the output ofcompile-file-pathname
.
prologue-code
andepilogue-code
are strings with C code to be executed before and after initializing the library, respectively. For dynamically linked libraries you can also provide a list of strings inld-flags
. These strings are additional parameters for the linker and their purpose is to link C/C++ extensions into the library.
init-name
gives the initialization function of the library a user-specified name. Thus a the generated library may be used and/or linked to a C application. The recommended way to invokeinit-name
is following:cl_object the_block = read_VV(OBJNULL, init_FOO /* function name specified by init-name */);Be sure to call
cl_boot
before the invocation ofinit-name
. In order to avoid that the returned object is garbage collected, you should keep the result ofread_VV
in a local variable.