[ External Interface | Reference Manual | Alphabetic Index ]

load(++File)

The object code or loadable library File is loaded into the running system.
File
Atom or a string.

Description

Used to load the object code file File into the ECLiPSe system. The object code would normally contain functions that implement ECLiPSe predicates via the external language interface. Such code can currently be written in C or C++. See the Embedding and Interfacing Manual for more detail.

On modern UNIX systems shared objects are used and loading is done using dlopen(). The argument of load/1 must be a shared object (.so file).

On Windows systems dynamic libraries are used. The argument of load/1 must be a .dll file.

To write portable programs, it is possible to query the value of the flag object_suffix. It gives the correct file extensions for the loadable objects on the current platform (e.g. "so", "dll").

Modes and Determinism

Exceptions

(4) instantiation fault
File is not instantiated.
(5) type error
File is instantiated, but not to an atom or a string.
(177) problem while trying to load a shared library
A shared library object (or one of its dependencies) could not be found

Examples

Success:

   % See the msg.c example source in external/2.
    % eclipse

   % load the .o file dynamically into the system
    [eclipse]: load('msg.so').
    yes.
    [eclipse]: get_flag(prmsg/1,visibility,Vis).
    accessing an undefined procedure

   % link the object file with a predicate definition.
    [eclipse]: external(prmsg/1,"p_prmsg").
    yes.

   % check on existence and flags of prmsg/1.
    [eclipse]: get_flag(prmsg/1,type,V),
               get_flag(prmsg/1,tool,T),
               get_flag(prmsg/1,visibility,Vis).
    V = user
    T = off
    Vis = local     More? (;)
    yes.

Error:
    [eclipse]: load('msg.c').
    system interface error: Unknown system error
              % not loading an object file.

    [eclipse]: load('msg.o').
    system interface error: No such file or directory
              % no compilation of msg.c to give msg.o

    load(F).                     (Error 4).
    load(msg(o)).                (Error 5).



See Also

call_c / 2, external / 1, external / 2, get_flag / 2