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&keylisp-filesprologue-codeepilogue-codeinit-name}Function:c:build-shared-library{library-name&keylisp-filesprologue-codeepilogue-codeld-flagsinit-name}This function builds a library file up from the object files listed in
lisp-files. Each of the arguments tolisp-filemust name a single object file produced withcompile-file.
library-nameis the physical pathname corresponding to the library. The value oflibrary-namemust follow some system-specific conventions. To make your program portable,library-nameshould be built using the output ofcompile-file-pathname.
prologue-codeandepilogue-codeare 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-namegives 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-nameis following:cl_object the_block = read_VV(OBJNULL, init_FOO /* function name specified by init-name */);Be sure to call
cl_bootbefore the invocation ofinit-name. In order to avoid that the returned object is garbage collected, you should keep the result ofread_VVin a local variable.