SBCL User Manual
Prev | Chapter 5. The Foreign Function Interface | Next

# Loading Unix Object Files

Foreign object files can be loaded into the running Lisp process by calling the functions `load-foreign` or `load-1-foreign`.

The `sb-alien:load-1-foreign` function is the more primitive of the two operations. It loads a single object file. into the currently running Lisp. The external symbols defining routines and variables are made available for future external references (e.g. by `extern-alien`). Forward references to foreign symbols aren't supported: `load-1-foreign` must be run before any of the defined symbols are referenced.

`sb-alien:load-foreign` is built in terms of `load-1-foreign` and some other machinery like `sb-ext:run-program`. It accepts a list of files and libraries, and runs the linker on the files and libraries, creating an absolute Unix object file which is then processed by `load-1-foreign`.

> Note: As of SBCL 0.7.5, all foreign code (code loaded with `load-1-function` or `load-function`) is lost when a Lisp core is saved with `sb-ext:save-lisp-and-die`, and no attempt is made to restore it when the core is loaded. Historically this has been an annoyance both for SBCL users and for CMU CL users. It's hard to solve this problem completely cleanly, but some generally-reliable partial solution might be useful. Once someone in either camp gets sufficiently annoyed to create it, SBCL is likely to adopt some mechanism for automatically restoring foreign code when a saved core is loaded.

Prev | Home | Next
Foreign Data Structure Examples | Up | Foreign Function Calls