The next three sections describe the major areas of Prolog that can be redefined to facilitate the embedding of Prolog code in foreign language applications:
main()
Consider the details presented in these sections in the context of this overview of the process of creating a program with a Prolog component:
prog.c
) and the Prolog code (component.pl
),
using the steps for the C calling Prolog interface described in
fli-ffp-bas-sum to call the Prolog predicates. Most likely you will
be defining a main()
routine; in this case be sure to call
QP_initialize()
. An example is found in the reference page.
component.pl
using qpc -c component.pl
prog.c
using e.g. cc -c prog.c
qld
. A typical call would be:
% qld -Dd component.qof prog.o -o BigApplication
You may also want to link in QUI in order to be able to use the debugger, as described in dbg-sld. The process of linking QUI into an application is discussed in sap-srs-qui.
gdb(1)
for C code, and Prolog debugging tools for Prolog code.
Quintus Prolog provides defaults for interfacing the operating system. If customization is necessary in this area, a user must completely redefine, not just extend, the supplied functions.
Please note: The default OS interface functions that can be redefined all have names beginning with the prefix
QU_
.The QU_ functions are like hooks in the sense that they provide you with a place to insert code that changes Prolog's behavior. However, we do not include Prolog hooks such as
message_hook/3
in this discussion because the point of embedding is to call Prolog code from foreign programs. The Prolog hooks are used independently of embedding.