tolUene
tolUene

Reputation: 584

compile with swi-prolog without including interactive prolog environment into binary

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

Answers (1)

gusbro
gusbro

Reputation: 22585

I would:

  • remove the :-initialization directive
  • compile with: swipl.exe -nodebug -g true -O -q --toplevel=main --stand_alone=true -o hello.exe -c hello.pro

That should do the trick

Upvotes: 3

Related Questions