Next: , Previous: , Up: Alien Objects   [Contents][Index]


8.6 Loading Unix Object Files

CMUCL is able to load foreign object files at runtime, using the function load-foreign. This function is able to load shared libraries (that are typically named .so) via the dlopen mechanism. It can also load .a or .o object files by calling the linker on the files and libraries to create a loadable object file. Once loaded, the external symbols that define routines and variables are made available for future external references (e.g. by extern-alien.) load-foreign must be run before any of the defined symbols are referenced.

Note that if a Lisp core image is saved (using save-lisp), all loaded foreign code is lost when the image is restarted.

Function: ext:load-foreign files &key :libraries :base-file :env

files is a simple-string or list of simple-strings specifying the names of the object files. If files is a simple-string, the file that it designates is loaded using the platform’s dlopen mechanism. If it is a list of strings, the platform linker ld is invoked to transform the object files into a loadable object file. libraries is a list of simple-strings specifying libraries in a format that the platform linker expects. The default value for libraries is ("-lc") (i.e., the standard C library). base-file is the file to use for the initial symbol table information. The default is the Lisp start up code: path:lisp. env should be a list of simple strings in the format of Unix environment variables (i.e., A=B, where A is an environment variable and B is its value). The default value for env is the environment information available at the time Lisp was invoked. Unless you are certain that you want to change this, you should just use the default.


Next: , Previous: , Up: Alien Objects   [Contents][Index]