Creating and calling a DLL

Your program's startup code (for DLL's)

If you are creating a DLL without C then you cannot have any initialization or termination processing. In this case do NOT issue the

:- public main/0.

declaration from any of the modules. Just link the modules together with a module definition file listing the names of the predicates you wish to export. Your module definition file will look something like this:

LIBRARY YourLibName
DESCRIPTION 'Anything you want'

EXPORTS
    abc_3   CONSTANT
    bcd_4   CONSTANT

When choosing symbols to export, remember that a Prolog predicate named, say, xyz/5, i.e. named xyz and with arity 5, uses the symbol xyz_5 as an entrypoint. In Win32, the CONSTANT keyword should be placed after Prolog exports, because they behave more like data exports than code exports.

An application that uses a DLL with Prolog entry points must make sure that initprolog has been called before calling any of the Prolog entry points.