Node:Interface Predicates, Next:The Foreign Resource Linker, Previous:Conversions, Up:Calling C
load_foreign_resource(:Resource)
Unless a foreign resource with the same name as Resource has been
statically linked, the linked foreign resource specified by
Resource is linked into the Prolog load image. In both cases, the
predicates defined by Resource are installed, and any init
function is called. Dynamic linking is not possible if the foreign
resource was linked using the static
option.
If a resource with the same name has been previously loaded, it will be
unloaded, as if unload_foreign_resource(Resource)
were
called, before Resource is loaded.
unload_foreign_resource(:Resource)
Any deinit function associated with Resource is called, and the predicates defined by Resource are uninstalled. If Resource has been dynamically linked, it is unlinked from the Prolog load image.
If no resource named Resource
is currently loaded, an
existence error is raised.
NOTE: all foreign resources are unloaded before Prolog exits. This
implies that the C library function atexit(func)
cannot be used
if func is defined in a dynamically linked foreign resource.
The following predicates are provided for backwards compatibility and should be avoided in new code:
foreign_file(+File,+Functions) [Hook,Obsolescent]
Specifies that a set of foreign functions,
to be called from Prolog, are to be found in File. This predicate
is only called from load_foreign_files/2
.
load_foreign_files(:ObjectFiles,+Libraries) [Hookable,Obsolescent]
A resource name is derived from the first file name in ObjectFiles by stripping off the suffix. If this resource has been statically linked, the predicates defined by it are installed; otherwise, a linked foreign resource containing the declared functions is created and loaded. Not available in runtime systems.