How can I compile a simple program in prolog?


I have SWI-Prolog installed, but I'm using it as a kind of interpreter, exp:

swi-pl?- [load]. True

I would like to know if there is a simple command that I can use via terminal to compile the source code into an executable.


According to :

For local use, you usually don't want to make an executable. Simply creating a script, as described in PrologScript , is easy and starts only a little slower in most cases.
A SWI-Prolog executable is a single file consisting of a system-native executable, with the saved-state attached to it. State is created using qsave_program/2 , as described in the manual.

You can create an .exe using qsave_program/2 or command line.
The command line below creates myapp.exe from and makes the program start from main/0 :

plcon -o myapp.exe -c --goal=main

To run myapp.exe, libpl.dll and any other dll called in the code must be in the same folder or in the %PATH% .

Scroll to Top