Package: cffi

Function load-foreign-library

Lambda List

load-foreign-library (library &key search-path)


library -- A library designator.
search-path -- A path or list of paths where the library will be searched if not found in system-global directories. Paths specified in a load clause take priority over paths specified as library option, with *foreign-library-directories* having lowest priority.

Return Value

An instance of foreign-library.


Load the library indicated by library.

A library designator is defined as follows:
  1. If a symbol, is considered a name previously defined with define-foreign-library.
  2. If a string or pathname, passed as a namestring directly to the implementation's foreign library loader. If that fails, search the directories in *foreign-library-directories* with cl:probe-file; if found, the absolute path is passed to the implementation's loader.
  3. If a list, the meaning depends on the value of (first library):
    The second list element is taken to be a Darwin framework name, which is then searched in *darwin-framework-directories*, and loaded when found.
    Each remaining list element, itself a library designator, is loaded in order, until one succeeds.
    The name is transformed according to the platform's naming convention to shared libraries, and the resultant string is loaded as a library designator. For example, on Unix, the name is suffixed with .so.
If the load fails, signal a load-foreign-library-error.

Please note: For system libraries, you should not need to specify the directory containing the library. Each operating system has its own idea of a default search path, and you should rely on it when it is reasonable.

Implementation-specific Notes

On ECL platforms where its dynamic FFI is not supported (i.e. when :dffi is not present in *features*), load-foreign-library does not work and you must use ECL's own ffi:load-foreign-library with a constant string argument.


See "Loading foreign libraries".

See also