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(
:ResourceName)
Any deinit function associated with ResourceName, a resource name, is called, and the predicates defined by ResourceName are uninstalled. If ResourceName has been dynamically linked, it is unlinked from the Prolog load image.
If no resource named ResourceName
is currently loaded, an
existence error is raised.
For backward compatibility, ResourceName can also be of the same
type as the argument to load_foreign_resource/1
. In that
case the resource name will be derived from the absolute file name in
the same manner as for load_foreign_resource/1
. Also for backward
compatibility, unload_foreign_resource/1
is a
meta-predicate, but the module is ignored.
Please note: all foreign resources are unloaded before Prolog exits. This implies that the C library functionatexit(
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)
development,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.