[ External Interface | The ECLiPSe Built-In Predicates | 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.

For old BSD systems, File specifies one or more object files, libraries and/or options in the form accepted by the UNIX linker ld(1). The argument is passed literally to the loader; the command executed is

   bin/ld -N -A <binary> -T <addr> -o /tmp/eclipse.<pid>.N <File> -lc 1>&2
   2>&2
where <pid> is the process ID of the ECLiPSe process and N is an integer that starts as zero and that is incremented after each dynamic loading.

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. "o", "so", "dll").

Fail Conditions

None.

Resatisfiable

No.

Exceptions

(4) instantiation fault
File is not instantiated.
(5) type error
File is instantiated, but not to an atom or a string.
(177) shared library not found
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