The utility program plld may be used to link a combination of C-files and Prolog files into a stand-alone executable. It is a simple Bourne-shell script that automates most of the steps outlined in the previous sections.
In the normal usage, a copy is made of the default embedding template
... /pl/include/stub.c. Additional foreign predicates are 
defined and added to the extension table PL_extensions. The 
main() routine is modified to suit your application. PL_initialise()
must be passed the program-name (argv[0]). 
The other elements of the command-line may be modified. Next, plld 
is typically invoked as:
plld will first split the options into various groups for both the C-compiler and the Prolog compiler. Next, it will add various default options to the C-compiler and call it to create an executable holding the user's C-code and the Prolog kernel. Then, it will call the SWI-Prolog compiler to create a saved state from the provided Prolog files and finally, it will attach this saved state to the created emulator to create the requested executable.
Below, it is described how the options are split and which additional options are passed.
-lpl 
and the libraries needed by the Prolog kernel are given.
-lpl for the current architecture is 
passed.
SWI-Prolog.h is passed. plld 
adds two additional * -Ddef flags:
__SWI_PROLOG__
__SWI_EMBEDDED__
*