Did you know ... Search Documentation:
qpforeign.pl -- Quintus compatible foreign loader
PublicShow source

This module defines a Quintus compatible foreign language interface based on the foreign_file/2 and foreign/3 declarations.

Predicates:

load_foreign_files
Load all foreign files defined with foreign_file/2 statement in the current module.
load_foreign_files(+Files, +Libs)
Load specified foreign files, linking them with the given libraries
load_foreign_files(+SharedObject, +Files, +Libs)
As load_foreign_files/2, but first tries to load `SharedObject'. If the SharedObject exists it is loaded using load_foreign_library/1. Otherwise it is first created with make_shared_object/3.
make_shared_object(+SharedObject, +Files, +Libs)
Generate a wrapper and link it using plld to the given SharedObject.
make_foreign_wrapper_file(+Files, +OutBase)
Generate wrapper for the named object files in OutBase.c.
make_foreign_wrapper_file(+Files)
Generate wrapper for all declared object files in OutBase.c.

Example:

foreign_file('-lm', [sin/2]).
foreign(sin, c, sin(+float, [-float])).
:- load_foreign_files,
   abolish(foreign_file, 2),
   abolish(foreign, 3).

Supported types:

SpecPrologC
integerintegerlong
floatfloat,integerdouble
singlefloat,integersingle
stringatom,stringchar *
atomatomatom identifier (type atomic)
NOTE This modules requires a correctly functioning swipl-ld and load_foreign_library/1 on your system. If this isn't the case use make_foreign_wrapper_file/[1,2] to generate a wrapper and use static embedding.
bug
- Only supports C-interface
- Insufficient checking for misusage.
- Documentation is too short and very outdated
Source load_foreign_files is det
Source load_foreign_files(:Files, +Libs) is det
Source load_foreign_files(+SharedObject, :Files, +Libs) is det
Calls make_foreign_wrapper_file(+File), compiles the wrapper and loads the predicates.
Source make_shared_object(+Object, :Files, +Libs) is det
Generate a wrapper and link it using plld to the given SharedObject.
Source make_foreign_wrapper_file(:OutFile) is det
Source make_foreign_wrapper_file(:Files, +OutFile) is det
Just output the wrapper file to the named .c file. May be used to prepare for static linking or the preparation of the native SWI-Prolog foreign-file.
Source make_foreign_resource_wrapper(:Resource, +ResBase, +FileBase)
Create a wrapper-file for the given foreign resource
Source load_foreign_resource(:Resource, +Dir)
Load a foreign module. First try to load from the same direcory as the Prolog file. Otherwise load using SWI-Prolog's default search path.