Next: Interface Data types
Up: Foreign Language Interface
Previous: Dynamic Linking of
This section discusses the functionality of the (autoload) library
shlib.pl, providing an interface to shared libraries. Currently it
supports MS-Windows DLL (.dll
) libraries and Unix .so
(shared object) files.
- load_foreign_library( +Lib)
Equivalent to load_foreign_library(Lib, install).
- load_foreign_library( +Lib, +Entry)
Search for the given foreign library and link it to the current
SWI-Prolog instance. The library may be specified with or without the
extension. It is searched for using the operating-system defined
searching mechanism. If the library can be loaded, the function
called Entry will be called without arguments. The return value
of the function is ignored.
The Entry function will normally call PL_register_foreign() to
declare functions in the library as foreign predicates.
- unload_foreign_library( +Lib)
If the foreign library defines the function uninstall
, this
function will be called without arguments and its return value is
ignored. Next, abolish/2 is used to remove all known foreign predicates
defined in the library. Finally the library itself is detatched from the
process.
- current_foreign_library( -Lib, -Predicates)
Query the currently loaded foreign libraries and their predicates.
Predicates is a list with elements of the form Module:Head,
indicating the predicates installed with PL_register_foreign().
Figure
connects a Windows message-box using a foreign
function. This example was tested using Windows-NT and Microsoft Visual
C++ 2.0.
Figure: MessageBox() example in Windows-NT
Passani Luca
Tue Nov 14 08:58:33 MET 1995