next up previous
Next: Static Linking Up: Linking Foreign Modules Previous: What linking is

What kind of loading should I be using?

All described approaches have their advantages and disadvantages. Static linking is portable and allows for debugging on all platforms. It is relatively cumbersome and the libraries you need to pass to the linker may vary from system to system.

Direct loading of object files is not very portable and generally works only on operating systems using the old BSD Unix a.out format for object and executable files. Also, the text of the loaded executable is in the data-segment of Prolog, disabling text-sharing and protection provided by Unix and some modern PC based operating systems.

Loading shared objects or DLL files provides sharing and protection and is generally the best choice. The problem is that save/[1,2] and save_program/[1,2] donot cooperate with this mechanism.

Summarising, if you donot need save/[1,2] or save_program/[1,2], loading based on library(shlib) is probably the best choice. See section gif. Otherwise use loading object files directly for small things and static linking for large applications to exploit sharing and protection.

Development in SWI-Prolog and operating systems are likely to make shlib the standard foreign loading schema for SWI-Prolog.

Note that the definition of the foreign predicates is the same, regardless of the linking type used.



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