All Manuals > LispWorks Delivery User Guide > 10 Delivery and Internal Systems

NextPrevUpTopContentsIndex

10.6 Delivery and the FLI

This section describes particular issues relevant to a delivered image containing Foreign Language Interface (FLI) code.

10.6.1 Foreign Language Interface templates

The Foreign Language Interface requires compiled code (known as FLI templates) to convert between foreign objects and Lisp objects. Most of these FLI templates are already available in the image, and most applications do not need extra templates.

However it is difficult to know in advance exactly which FLI templates will be needed. When a new template is actually required, it is compiled. In a delivered image where the compiler has been removed, this causes an error like this:

FLI template needs to be compiled
(see 'Foreign Language Interface templates' in the LispWorks Delivery User Guide):
  (FLI::DEFINE-PRECOMPILED-FOREIGN-OBJECT-SETTER-FUNCTIONS ((:FLOAT :SIZE 4)))

To solve this you need to find which templates your application uses that are not already available, compile them, and load them before delivering.

To find which templates your application needs, do the following:

  1. Start the undelivered application image (that is, LispWorks with your application code loaded).
  2. Call
  3. (FLI:START-COLLECTING-TEMPLATE-INFO)
  4. Fully exercise the application. You must test thoroughly all the functionality of the application to ensure that any code that needs templates gets run.
  5. Call
(FLI:PRINT-COLLECTED-TEMPLATE-INFO)

This prints all the templates that were generated while exercising your application. These FLI template forms should be put in a file which is compiled and loaded as part of your application. FLI:PRINT-COLLECTED-TEMPLATE-INFO takes a keyword :OUTPUT-STREAM to make this easier, for example:

(with-open-file (stream "fli-templates.lisp" :direction :output)
                (FLI:PRINT-COLLECTED-TEMPLATE-INFO 
                  :OUTPUT-STREAM stream
))

Once you have compiled the file containing the templates, it should be loaded as part of your application.

10.6.2 Foreign callable names

In most cases foreign callable names are passed to deliver in the value of the :dll-exports keyword argument, and each of these foreign callables will be retained automatically in the delivered image.

However other foreign callables defined with a string foreign-name are liable to be shaken from the delivered image. The best approach is to use a symbol to name such foreign callables, as described under fli:define-foreign-callable in the LispWorks Foreign Language Interface User Guide and Reference Manual .


LispWorks Delivery User Guide - 10 Aug 2017

NextPrevUpTopContentsIndex