I am learning prolog, and I use swi-prolog as a compiler/interpreter. I have this hello world file:
:- initialization(main).
main :- format('Hello, world').
but when I try to compile it with swipl -o hello.exe -c hello.pro
and run the binary hello.exe
, it runs the goal first (main) but then returns me to the swi-prolog interactive environment. How do I just compile it so it's a functioning program without the prolog environment?
I also tried adding halt
at the end of main, but that doesn't compile at all. When I try that, the compiler prints "Hello, world" and then just stops compiling.
halt
aftermain
inside the initialization directive? Or that you addedhalt
as the tail call in definingmain/0
? – hardmathmain/0
. – tolUene