# Can swipl.exe load library(pce)?

**URL:** <https://swi-prolog.discourse.group/t/can-swipl-exe-load-library-pce/5376>\
**Category:** Tools\
**Tags:** how-to\
**Created:** [May 5, 2022, 4:51pm UTC](https://swi-prolog.discourse.group/t/can-swipl-exe-load-library-pce/5376 "2022-05-05T16:51:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chansey97](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@chansey97](https://swi-prolog.discourse.group/u/chansey97)\
**Post date:** [May 5, 2022, 4:51pm UTC](https://swi-prolog.discourse.group/t/can-swipl-exe-load-library-pce/5376/1 "2022-05-05T16:51:33Z")

</div>

I have a `.pl` file with the following content:

```prolog
;; xpce.pl
:- use_module(library(pce)).

```

but `swipl.exe` can not load it:

```prolog
?- consult([xpce]).
ERROR: e:/work-pl/prolog/code/xpce/xpce.pl:1:
ERROR: source_sink `library(pce)' does not exist
Warning: e:/work-pl/prolog/code/xpce/xpce.pl:1:
Warning: Goal (directive) failed: user:use_module(library(pce))
true.

```

To load this file correctly, I have to use `swipl-win.exe` instead.

Is there way to workaround it?

Thanks.

P.s. I am using GNU Emacs to edit Prolog files. For console applications, `prolog-mode` and `ediprolog` works well with `swipl.exe`, but for graphics applications, I have to use `swipl-win.exe` which `prolog-mode` and `ediprolog` do not support.

---

<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 5, 2022, 5:17pm UTC](https://swi-prolog.discourse.group/t/can-swipl-exe-load-library-pce/5376/2 "2022-05-05T17:17:49Z")

</div>

> [@chansey97](#):
>
> Is there way to workaround it?

No ☹`swipl.exe` is a Windows console application and `swipl-win.exe` is a Windows GUI application. The console application cannot use graphics which stops xpce and the GUI application doesn’t have stdio streams Emacs can work with.

This does work on other platforms that do not make this distinction (MacOS, Linux) and thus you can run `swipl` under Emacs _and_ use graphics.

---

<div class="post-metadata">

**Author:** ![chansey97](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@chansey97](https://swi-prolog.discourse.group/u/chansey97)\
**Post date:** [May 5, 2022, 5:39pm UTC](https://swi-prolog.discourse.group/t/can-swipl-exe-load-library-pce/5376/3 "2022-05-05T17:39:58Z")

</div>

> [@jan](#):
>
> The console application cannot use graphics which stops xpce

Even if console application cannot use graphics, I would like to at least be able to make `swipl.exe` load `library(pce)`. Because most of programming time we are just working with data. Graphics are only for final display.

BTW, why console applications cannot use graphics? The other day, I tried [plOpenGL](https://swi-prolog.discourse.group/t/looking-for-a-little-game-prototype-code-snippets-in-swi-prolog/5366/3) which uses graphics. It can work with `swipl.exe`. For example, in Emcas `shell-mode`, I can run `c:\swipl.exe myOpenGLapp.pl`, it will display a window (there are some problems with `prolog-mode` and `ediprolog` though).

---

<div class="post-metadata">

**Author:** ![chansey97](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@chansey97](https://swi-prolog.discourse.group/u/chansey97)\
**Post date:** [May 6, 2022, 6:38am UTC](https://swi-prolog.discourse.group/t/can-swipl-exe-load-library-pce/5376/4 "2022-05-06T06:38:24Z")

</div>

I found a workaround in the forum by @he_deceives : [XPCE windows freeze with swipl but not swipl-win](https://swi-prolog.discourse.group/t/xpce-windows-freeze-with-swipl-but-not-swipl-win/1016)

> [@XPCE windows freeze with swipl but not swipl-win](https://swi-prolog.discourse.group/t/xpce-windows-freeze-with-swipl-but-not-swipl-win/1016/1):
>
> First, the program had problems with the use\_module(library(pce)) load, but I fixed this by copying the swipl-win.rc file in the installation directory file to my user directory and renaming it to swipl.rc.

I copied and renamed it to the same installation directory, rather than user directory. Of course, this workaround will freeze the window when actually run graphics pp, but at least can it load successfully.

---

<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 6, 2022, 7:05am UTC](https://swi-prolog.discourse.group/t/can-swipl-exe-load-library-pce/5376/5 "2022-05-06T07:05:14Z")

</div>

You can simply do `copy swipl-win.rc swipl.rc` in the install directory of start Prolog using

```
swipl.exe -F swipl-win

```

Or add to your init.pl file `:- use_module(swi('swipl-win.rc')).`

It seems that since xpce by default runs in a background thread, `swipl.exe` is now capable of opening xpce windows. At least `?- emacs.` seems to work just fine.

As a side note, there is not that much point in spending time on xpce. Its state is still very unclear. It has some nice properties. It is also very outdated. It is not very likely to be abandoned as the development tools use it and there are quit a few applications out there. The whole thing would need a big overhaul. Think about modern graphics, but also more low-level issues like threading and memory management. That is not very likely to happen any time soon (if ever).
