Building DLLs containing Prolog code

This section is only relevant for Windows.

It is possible to build DLLs containing Prolog code to be linked dynamically into applications. Packaging your code as a DLL promotes sharing and is also a requirement for applications where an application needs to dynamically link your code. An example illustrating this and other techniques that are useful when embedding Prolog in C is the Visual Basic interface source code; see quintus-directory\src\vbqp.

Applications typically look for DLLs in the same directory as the application itself and also in any directories specified in the PATH environment variable. Applications also look in some system directories but that is less useful for our purposes.

The easiest way to ensure that the DLL (and the Quintus runtime DLLs) are found is to put the DLL together with the Quintus runtime DLLs in runtime-directory and then ensure that the PATH environment variable is set up to include that directory, as described below.

Another method, especially suitable for running on a machine where Quintus Prolog is not installed, is to put all the DLLs in the same directory as the application. This includes the DLL built as below and the appropriate Quintus runtime DLLs.

See the Microsoft documentation for more information about DLLs.

To build a DLL containing Prolog code, follow these steps: