load_foreign_files/2 is an alternative interface to
load_foreign_executable/1, which constructs a shared object file
from the list of object files and libraries given as its arguments
and then maps the resulting shared object file into the Prolog
address space. In general it is recommended that you take
the responsibility for the construction of a shared object file and
load_foreign_files/2 is slower because it
has to invoke the linker to construct the shared object file everytime the
program is loaded.
A further disadvantage is that the linker may not be available at
runtime on all systems.
% cc -c CFLAGS math.c % cc -c CFLAGS other.c % prolog | ?- compile(foreign). | ?- load_foreign_files([math,other],['-lm']).
Again, the file
foreign.pl) contains the
facts that describe how Prolog is to call the foreign functions.
If the extensions on filenames given in the first argument to
load_foreign_files/2 are omitted, the proper extension is automatically
appended to them.