Next: , Previous: , Up: Top   [Contents][Index]


14 Static Linking

On recent enough versions of supported implementations (currently, GNU CLISP 2.49 or later, CMUCL 2015-11 or later, and SBCL 1.2.17 or later, except SBCL 2.0.4), and with a recent enough ASDF (3.1.2 or later), you can create a statically linked Lisp executable image (or a standalone application executable) that includes all the C extensions defined via The Groveller’s :cffi-wrapper-file ASDF components (and any other such objects output by asdf:compile-op), as well as those defined by :c-file or :o-file ASDF components, and your Lisp code. This makes it easier to deliver your code as a single file.

Note that the resulting binary will typically still depend on any shared libraries loaded via See load-foreign-library or See use-foreign-library as well as core libraries such as libc.

To dump a statically linked executable image, use:

  (asdf:load-system :cffi-grovel)
  (asdf:operate :static-image-op :example-software)

To dump a statically linked executable standalone application, use:

  (asdf:load-system :cffi-grovel)
  (asdf:operate :static-program-op :example-software)

See the ASDF manual for documentation about image-op and program-op which are the parent operation classes that behave similarly except they don’t statically link C code.

Implementor’s note: There is also an operation :static-runtime-op to create the statically linked runtime alone, but it’s admittedly not very useful except as an intermediate step dependency towards building :static-image-op or :static-program-op.