1.4. Building libraries

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 to lisp-file must name a single object file produced with compile-file.

library-name is the physical pathname corresponding to the library. The value of library-name must follow some system-specific conventions. To make your program portable, library-name should be built using the output of compile-file-pathname.

prologue-code and epilogue-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 in ld-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 invoke init-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 of init-name. In order to avoid that the returned object is garbage collected, you should keep the result of read_VV in a local variable.