This chapter describes utilities useful for generating glue code for the Foreign Language Interface when building statically linked Runtime Systems or Development Systems (see section Interface Predicates).
This library module can be loaded by the query
| ?- use_module(library(flinkage)).
and refers to the following shared object files or DLLs:
The following predicate can be used to generate a glue code file
`flinkage.c' file out of any old-style
foreign/(2,3) declarations found in a set of Prolog files for use
in a statically linked executable.
Note: this is provided for backwards compatibility only. We
recommend using foreign resources instead, which can be dynamically
use_module/1. Calls to
load_foreign_files/2are intercepted by means of the goal expansion mechanism. The file `flinkage.c' is generated out of the declarations found. Finally, compile and link the `flinkage.c' file with the user code, libraries and the runtime and optionally the development kernel.
The following predicates, available in Development Systems only, provide alternative methods to building executables or linked foreign resources compared to the methods described in section Creating the Executable, section Development Systems and section Creating the Linked Foreign Resource. If the default method doesn't work as expected for some reason or you wish to use an Integrated Development Environment etc., the following outlines the necessary steps. To build an executable:
First, decide which foreign resources are to be statically linked and create a resource table file as follows:
The next step is to create linked foreign resources from the foreign resources which are to be statically linked. Produce, for each foreign resource, a glue code file using:
Finally, compile and link the glue code files with the user code, libraries and the runtime and optionally the development kernel. Further information (platform specific) is provided with the distribution.
To build a dynamic linked foreign resource:
Produce a glue code file using
the provided platform specific notes for compiler options needed and
compile the glue code file and the user code files. Likewise check the
notes on how a dynamic linked foreign resource is implemented on this
platform and link the object files to an appropriate object.
Go to the first, previous, next, last section, table of contents.