Now that WSL 2 can install WSLg (graphics for WSL) without being on the Windows Insider Program (ref), how does one start SWI-Prolog on Ubuntu on WSL 2 on Windows so that gtrace/0 can be used?
Answer:
At present it seems that gtrace and the goal have to be run with a conjunction (,
), e.g.
?- gtrace,between(1,5,N).
not with gtrace as one goal followed the other goal, e.g.
?- gtrace.
?- between(1,5,N).
TL;DR
As a Windows user would just start SWI-Prolog by clicking on the a task bar shortcut for "C:\Program Files\swipl\bin\swipl-win.exe" --win_app
As a command line Ubuntu user would just run swipl
from the command line.
When a GUI was needed would run and X11 server (VcXsrv) (ref), while it did work it left open a large security hole so was not actively used.
Other users have noted here that WSLg is great but at that time required being on the Windows Insider Program. Now it seems that is no longer a constraint.
To test if GUI is working for WSL 2 with WSLg
$ sudo apt install x11-apps -y
$ xcalc
which then displays a graphical calculator. Did not need to install a separate X11 server or anything, it just works as expected.
This SWI-Prolog example displayed a GUI window when run (ref)
new(X,picture),send(X,open(point(200,200))).
Another piece of evidence appears.
Running gtrace on a line by itself then running the goal will not make the gtrace window appear.
If running gtrace and the goal as a conjunction (,
), the gtrace window appears.
groot@Galaxy:~$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.5.14-11-gb91bcb590)
?- gtrace,between(1,5,N).
% The graphical front-end will be used for subsequent tracing
N = 1