Reputation: 584
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.
Upvotes: 1
Views: 873
Reputation: 22585
I would:
:-initialization
directiveswipl.exe -nodebug -g true -O -q --toplevel=main --stand_alone=true -o hello.exe -c hello.pro
That should do the trick
Upvotes: 3