% cc -G -I/usr/local/eclipse/include/sparc_sunos5 -o eg_externals.so eg_externals.cor
% cc -shared -I/usr/local/eclipse/include/i386_linux -o eg_externals.so eg_externals.cIf the external is to be used in a standalone ECLiPSe, it is possible to dynamically load it using the load/1 predicate:
load("eg_externals.so")On older UNIX platforms without dynamic loading, the following method may work. Compile the source using
% cc -c -I/usr/local/eclipse/include/sparc_sunos5 eg_externals.cand load it with a command like
load("eg_externals.o -lg -lm")The details may vary depending on what compiler and operating system you use. Refer to the Makefile.external for details.
Once the object file containing the C function has been loaded into ECLiPSe, the link between the function and a predicate name is made with external/2
external(sumlist/2, p_sumlist)The new predicate can now be called like other predicates. Note that the external/2 declaration must precede any call to the declared predicate, otherwise the ECLiPSe compiler will issue an inconsistent redefinition error. Alternatively, the external/1 forward declaration can be used to prevent this.