# XPCE standalone executable (Windows 10)

**URL:** <https://swi-prolog.discourse.group/t/xpce-standalone-executable-windows-10/5396>\
**Category:** Tools\
**Created:** [May 16, 2022, 9:41am UTC](https://swi-prolog.discourse.group/t/xpce-standalone-executable-windows-10/5396 "2022-05-16T09:41:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![duesentrieb17](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/duesentrieb17/32/4333_2.png) [@duesentrieb17](https://swi-prolog.discourse.group/u/duesentrieb17)\
**Post date:** [May 16, 2022, 9:41am UTC](https://swi-prolog.discourse.group/t/xpce-standalone-executable-windows-10/5396/1 "2022-05-16T09:41:45Z")

</div>

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](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/0/09539c13070b2b86ffdff955354e854f95179a0d.png)

```prolog
:-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](https://www.swi-prolog.org/FAQ/PceWinExe.txt) is outdated and therefore gives no indication of what I would need to adjust in the program.

---

<div class="post-metadata">

**Author:** ![drspro](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/drspro/32/3509_2.png) [@drspro](https://swi-prolog.discourse.group/u/drspro)\
**Post date:** [May 18, 2022, 9:57am UTC](https://swi-prolog.discourse.group/t/xpce-standalone-executable-windows-10/5396/2 "2022-05-18T09:57:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [May 18, 2022, 11:32am UTC](https://swi-prolog.discourse.group/t/xpce-standalone-executable-windows-10/5396/3 "2022-05-18T11:32:59Z")

</div>

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

```prolog
:-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 …

---

<div class="post-metadata">

**Author:** ![jeangil](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jeangil/32/4751_2.png) [@jeangil](https://swi-prolog.discourse.group/u/jeangil)\
**Post date:** [August 15, 2022, 1:38pm UTC](https://swi-prolog.discourse.group/t/xpce-standalone-executable-windows-10/5396/4 "2022-08-15T13:38:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [August 17, 2022, 8:39am UTC](https://swi-prolog.discourse.group/t/xpce-standalone-executable-windows-10/5396/5 "2022-08-17T08:39:47Z")

</div>

`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.

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [August 17, 2022, 9:56am UTC](https://swi-prolog.discourse.group/t/xpce-standalone-executable-windows-10/5396/6 "2022-08-17T09:56:00Z")

</div>

> [@jan](#):
>
> Of course you do need to include the xpce2pl.dll (If I recall correctly) file.

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**
>
> ```plaintext
> 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`. 🙂

* * *

To show that XPCE is working ran this XPCE example. ([ref](https://www.swi-prolog.org/packages/xpce/examples.txt))

```prolog
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](https://global.discourse-cdn.com/free1/uploads/swiprolog/original/2X/b/bcc0ff513336ae808317f62bf58290023a0a8826.png)

---

<div class="post-metadata">

**Author:** ![jeangil](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jeangil/32/4751_2.png) [@jeangil](https://swi-prolog.discourse.group/u/jeangil)\
**Post date:** [August 17, 2022, 5:57pm UTC](https://swi-prolog.discourse.group/t/xpce-standalone-executable-windows-10/5396/7 "2022-08-17T17:57:36Z")

</div>

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:

```prolog
:- 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

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [August 17, 2022, 8:06pm UTC](https://swi-prolog.discourse.group/t/xpce-standalone-executable-windows-10/5396/8 "2022-08-17T20:06:24Z")

</div>

> [@jeangil](#):
>
> `:- my_first_program.`

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.

```prolog
:- 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.

---

<div class="post-metadata">

**Author:** ![jeangil](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jeangil/32/4751_2.png) [@jeangil](https://swi-prolog.discourse.group/u/jeangil)\
**Post date:** [August 18, 2022, 5:11pm UTC](https://swi-prolog.discourse.group/t/xpce-standalone-executable-windows-10/5396/9 "2022-08-18T17:11:25Z")

</div>

Dear Jan,

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

Regards

Jeangil
