XPCE standalone executable (Windows 10)

The following program uses the XPCE internal bitmap image named ‘icon’.
With version 5.9.7, the program also runs as a standalone executable without a problem.
But with version 8.4.2 I get the following error:
SWI-Prolog-8.4.2-error

:-use_module([library(pce)]).

resource(icon, image, 'edit.xpm').

test :-
  new(ViewR, view(view, size(120, 30))),
  send(ViewR, icon, resource(icon)),
  send(ViewR, open).

The FAQ article Making an executable for XPCE/SWI-Prolog applications in MS-Windows is outdated and therefore gives no indication of what I would need to adjust in the program.

I also use XPCE on windows every day for an office system CRM system to make Pdfs and thunderbird emails and to save customer data. I do not use the bitmaps so i do not have this problem.

Swi prolog makes commandline batch files to an Usb-stick which in turn are read by swi-prolog on Linux which calls Thunderbird in the commandline interface with the right data, subject , to-email , email-text, html-body, and also Pdf attachment

As is, it doesn’t run without saving either. The minimal program I could get to run was

:-use_module(library(pce)).

resource(icon, image, image('16x16/edit.xpm')).

test :-
  new(ViewR, view(view, size(120, 30))),
  send(ViewR, icon, resource(icon)),
  send(ViewR, open).

Note that xpce-stub.exe no longer exists and you should xpce-win.exe and if all works fine you can use win_window_pos/1 to hide the Prolog console (it will briefly flash). No clue whether all this still works …

Dear Mr,
I have made, with success, an executable file using, on windows = swipl-win.exe -o myapp.exe -c load.pl --goal=main.

But when trying to make an executable for simple application with XPCE /SWI prolog application (simple window application) with the same instructions, nothing happen !!

In your last post, You were talking about xcpe-win.exe application ( which I suppose is for making executable with XPCE /SWI prolog application ?)
But I can’t find it anywhere .
May be could you give me some more information to solve my problem ?

Thanks for your help.

jeangil

xpce-win.exe no longer exists. Creating an executable including graphics (using xpce) shouldn’t differ too much from a normal executable based on swipl-win.exe. Of course you do need to include the xpce2pl.dll (If I recall correctly) file. First thing to try is probably to dump the exe you created in the bin directory of the installation and check that it works.

Note that if all is working, you can hide the Prolog console window using win_window_pos/1.

FYI

In searching my Windows install of SWI-Prolog 8.5.15 which supports the GUI here are the DLLs in C:\Program Files\swipl\bin

Click to see list of DLLs
archive4pl.dll
bdb4pl.dll
cgi.dll
crypt.dll
crypto4pl.dll
double_metaphone.dll
files.dll
hashstream.dll
http_stream.dll
inclpr.dll
isub.dll
jpl.dll
json.dll
libarchive-13.dll
libcrypto-1_1-x64.dll
libdb-6.1.dll
libgcc_s_seh-1.dll
libgmp-10.dll
libjpeg-62.dll
libpcre2-8-0.dll
libssl-1_1-x64.dll
libssp-0.dll
libswipl.dll
libwinpthread-1.dll
libyaml-0-2.dll
md54pl.dll
memfile.dll
ntriples.dll
odbc4pl.dll
pcre4pl.dll
pdt_console.dll
pl2xpce.dll
plregtry.dll
plterm.dll
porter_stem.dll
process.dll
prolog_stream.dll
protobufs.dll
rdf_db.dll
readutil.dll
redis4pl.dll
sgml2pl.dll
sha4pl.dll
snowball.dll
socket.dll
ssl4pl.dll
streaminfo.dll
table.dll
tex.dll
time.dll
turtle.dll
unicode4pl.dll
uri.dll
uuid.dll
websocket.dll
yaml4pl.dll
zlib1.dll
zlib4pl.dll

I did not find xpce2pl.dll but there is pl2xpce.dll. :slightly_smiling_face:


To show that XPCE is working ran this XPCE example. (ref)

Welcome to SWI-Prolog (threaded, 64 bits, version 8.5.15)

?- new(X,picture),send(X,open(point(200,200))).
X = @239305369623/picture.

which creates

image

thanks to you for reply,

It’s working, but my graphic.exe application (simple window) no longer stay on screen.

May be, I forgot something ?

Could you tell me where is the pb ?

here is the code:

:- use_module(library(pce)).
my_first_program :-

   % create window
   new(D, window('my_first_window')),
   
   % give it the right size
   send(D, size, size(250, 100)),
   
   % create text
   new(T, text('Hello World !')),
   
   % ask window to position text in the middle
   send(D, display, T, point(80, 40)),
   
   % send to window displaying msg.
   send(D, open).

% start the demo
:- my_first_program.

Thanks for your help,

Jeangil

This is not going to work as simple :- Goal are only called when the program is loaded. A minimal reasonable example is below. The pce_main_loop/1 predicate keeps the application alive as long as there are open windows.

:- use_module(library(pce)).
:- use_module(library(pce_main)).

my_first_program(_Argv) :-
   new(D, window('my_first_window')),
   send(D, size, size(250, 100)),
   new(T, text('Hello World !')),
   send(D, display, T, point(80, 40)),
   send(D, open).

main :-
   win_window_pos([show(false)]),
   pce_main_loop(my_first_program).

:- initialization(main, main).

Build using

swipl-win.exe -o prog.exe -c prog.pl

and make sure all dlls are around. Works for me, including terminating the application after closing the window.

Dear Jan,

It’s working !!! :grinning:
Thanks a lot for your help,

Regards

Jeangil