next up previous
Next: Dynamic Linking of Up: Dynamic Linking based Previous: Dynamic Linking based

Portability Note

The incremental linker is highly system dependent. It can easily be ported to machines for which the C linker allows you to link an object file using the symbol table of a (running) executable and use BSD Unix format a.out files. On many Unix systems such an object file can be created using the -A option of ld(1). Some operating systems offer primitives for dynamic loading (AIX, MACH). The following call may be used to find out whether load_foreign is functional:

?- feature(load_foreign, OK).

load_foreign( +File, +Entry)

  Load a foreign file or list of files specified by File. The files are searched for similar to consult/1. Except that the `.o ' extension is used rather than `.pl '. Thus `test ' is a valid specification for `test.o ' in the current directory, `[test, library(basics)] ' specifies `test.o ' in the current directory and `basics.o ' in one of the library directories.

Entry defines the entry point of the resulting executable. The entry point will be called by Prolog to install the foreign predicates.

load_foreign( +File, +Entry, +Options, +Libraries, +Size)

  The first two arguments are identical to those of load_foreign/2. Options is (a list of) additional option to be given to the loader. The default command is: gif

$(CC) -N -A <symbolfile> -T <offset> -e <entry> -o <executable>
   <files> -lc

The options are inserted just before the files. Libraries is (a list of) libraries to be passed to the loader. They are inserted just after the files.

If Size is specified Prolog first assumes that the resulting executable will fit in Size bytes and do the loading in one pass. If the executable turns out to be larger than Size bytes the loading sequence is started again, using the calculated size. To determine the size of an executable specify a size that is too small. Prolog will then print the actual size on the current output stream.

foreign_file( ?File)

  Is true if File is the absolute path name of a file loaded as foreign file.



next up previous
Next: Dynamic Linking of Up: Dynamic Linking based Previous: Dynamic Linking based



Passani Luca
Tue Nov 14 08:58:33 MET 1995