load_foreign_files/2 hookable

Synopsis

load_foreign_files(+ObjectFiles, +Libraries)

Loads foreign object files into Prolog. Relies on the hook predicates foreign_file/2 and foreign/[2,3].

Arguments


ObjectFiles list of file_spec [MOD]
A list of foreign object files to be loaded.
Libraries list of atom
A list of shared libraries that need to be searched while loading ObjectFiles.

Description

load_foreign_files/2 takes a list of object files and a list of shared libraries, links them and then loads the result into Prolog. The linking is done using the system linker. For details on the call to the linker, see fli-p2f-lff.

The extension can be omitted from the filenames given in the ObjectFiles argument.

Uses the foreign/3 and foreign_file/2 facts defined by the user to make the connection between a Prolog procedure and the foreign function. When loading each object file, it looks for a foreign_file/2 fact for the object file and for each symbol in the foreign_file/2 fact it looks for a foreign/3 fact that gives the name of the Prolog procedure associated with the foreign symbol and the argument specification.

Looks for foreign/3 and foreign_file/2 facts defined in its source module only.

Looks at the environment variable TMPDIR for the directory to store all the temporary files created during the linking and loading process. The default directory is /tmp.

Before calling this predicate, generate the object files for the foreign functions using the foreign language compiler. The object files should contain position independent code; see fli-p2f-uso.

Exceptions

Errors in the specification of foreign/3 will all be reported when load_foreign_files/2 is called.

Examples

See example under foreign/[2,3]

See Also

foreign_file/2, foreign/[2,3], load_foreign_executable/1 fli-p2f