This section describes particular issues relevant to a delivered image containing Foreign Language Interface (FLI) code.
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:
(FLI:START-COLLECTING-TEMPLATE-INFO)
(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.
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 - 15 Feb 2015