# Find swipl

**URL:** <https://swi-prolog.discourse.group/t/find-swipl/5109>\
**Category:** Predicate\
**Created:** [March 9, 2022, 7:32am UTC](https://swi-prolog.discourse.group/t/find-swipl/5109 "2022-03-09T07:32:25Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [March 9, 2022, 7:32am UTC](https://swi-prolog.discourse.group/t/find-swipl/5109/1 "2022-03-09T07:32:25Z")

</div>

Dear friends,

How do I “find” swipl? In linux, I can type swipl --dump-runtime-variables, and I get the necessary information. Is there a similar heuristic under Windows and macOS?

Best wishes,

Matthias

---

<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:** [March 9, 2022, 8:49am UTC](https://swi-prolog.discourse.group/t/find-swipl/5109/2 "2022-03-09T08:49:44Z")

</div>

Well, `swipl --dump-runtime-variables` works on all platforms. So, if swipl[.exe] is on `$PATH` or `%PATH%` (Windows) you are fine. On Linux and MacOS that is typically the case. On Windows that is less common. I think the system used to be findable from the registry, but this no longer seems the case by the `cpack` generated installer. Typically you find it under `swipl\bin\swipl.exe` under _Program Files_

---

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [March 9, 2022, 9:14am UTC](https://swi-prolog.discourse.group/t/find-swipl/5109/3 "2022-03-09T09:14:30Z")

</div>

So, this seems not to work (from Pack.cmake):

set(CPACK\_NSIS\_EXTRA\_INSTALL\_COMMANDS "  
WriteRegStr HKLM ‘Software\\SWI\\Prolog’ ‘fileExtension’ ‘pl’  
WriteRegStr HKLM ‘Software\\SWI\\Prolog’ ‘home’ ‘$INSTDIR’  
")

I’ll have a look.

---

<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:** [March 9, 2022, 9:26am UTC](https://swi-prolog.discourse.group/t/find-swipl/5109/4 "2022-03-09T09:26:45Z")

</div>

Thanks. It does seem to work 🙂

---

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [March 9, 2022, 12:48pm UTC](https://swi-prolog.discourse.group/t/find-swipl/5109/5 "2022-03-09T12:48:00Z")

</div>

Found it!

Computer\HKEY\_LOCAL\_MACHINE\SOFTWARE\WOW6432Node\SWI\Prolog

Whatever this WOW6432Node is…

Thanks!

---

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [March 10, 2022, 8:09pm UTC](https://swi-prolog.discourse.group/t/find-swipl/5109/6 "2022-03-10T20:09:44Z")

</div>

Ah, there’s still a little problem.

The thing is that the registry entry is basically needed when PATH is not set to c:/program files/swipl/bin. This happens if the user forgets it, or, and that’s the more interesting case, in dual installations of both the 32 and 64 bit version of swipl. Then you don’t want the path point to both versions of swipl.

Unfortunately, in that case, both installations write to the same registry key. If you don’t mind, I’ll add two more keys, home32 and home64 so that the correct swipl home is found.

PS. In case you’re wondering, why would anyone want a dual installation of 32 and 64 bit. Basically, never. However, in current R 4.1, packages are installed for both 32 and 64 bit, which is silly as well. It is the default, though, and if I install a new package, the system tries to compile it for both 32 and 64 bit. Therefore, if one wants R to connect to an existing installation of swipl (not embedded), both 32 and 64 bit are needed. 32 bit support will end with R-4.2, but that’s another half a year, and I kinda like the idea of supporting old hardware if that is possible with reasonable efforts.

---

<div class="post-metadata">

**Author:** ![dgelessus](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/dgelessus/32/3106_2.png) [@dgelessus](https://swi-prolog.discourse.group/u/dgelessus)\
**Post date:** [March 10, 2022, 10:08pm UTC](https://swi-prolog.discourse.group/t/find-swipl/5109/7 "2022-03-10T22:08:38Z")

</div>

Strange - normally, the WOW6432Node subtree should only be used by 32-bit programs. Windows automatically redirects 32-bit programs into WOW6432Node to avoid conflicts with native 64-bit programs, which use the normal SOFTWARE tree.

I’m wondering why the 64-bit SWI path is also written into WOW6432Node. Maybe the SWI _installer_ is always 32-bit, so the registry writes get redirected even when installing the 64-bit version?

If this was working correctly, there would be no need to manually rename the registry key. The 64-bit version should be at SOFTWARE\SWI\Prolog, and only the 32-bit version would use SOFTWARE\WOW6432Node\SWI\Prolog.

---

<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:** [March 11, 2022, 7:33am UTC](https://swi-prolog.discourse.group/t/find-swipl/5109/8 "2022-03-11T07:33:49Z")

</div>

Seems we first need to sort out what really happens when doing a fresh install of both the win32 and 64 versions on a clean 64-bit Windows environment.

---

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [March 11, 2022, 8:55am UTC](https://swi-prolog.discourse.group/t/find-swipl/5109/9 "2022-03-11T08:55:46Z")

</div>

For what it is worth, the SWI installer is indeed a 32 bit program for both 32 and 64 bit swipl.

---

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [March 11, 2022, 9:02am UTC](https://swi-prolog.discourse.group/t/find-swipl/5109/10 "2022-03-11T09:02:22Z")

</div>

It seems as if the architecture can be changed easily,

> **[Making 64-bit installers with CMake and NSIS](http://whatnicklife.blogspot.com/2013/07/making-64-bit-installers-with-cmake-and.html)**
>
> I was getting tired of my 64-bit programs getting installed by NSIS into the x86 folder under windows, just because the NSIS installer itse...

So the “only” thing that would need to be changed is line 4 of swipl-devel/cmake/cpack.cmake:

from:  
set(CPACK\_GENERATOR “NSIS”)

to:  
if(CMAKE\_SIZEOF\_VOID\_P EQUAL 8)  
set(CPACK\_GENERATOR “NSIS64”)  
else()  
set(CPACK\_GENERATOR “NSIS”)  
endif()

(assuming that NSIS64 is found in the crosscompiler installation)

---

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [March 11, 2022, 10:52am UTC](https://swi-prolog.discourse.group/t/find-swipl/5109/11 "2022-03-11T10:52:41Z")

</div>

(edit: ok, I can set MINGW\_ROOT to point to the respective folder)

I tried to test this for the crosscompilation (according to README.mingw), but I am stuck at the cmake configuration:

```prolog
W64 (build.win64; master) 550_> cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/cross/linux_win64.cmake -DJAVA_COMPATIBILITY=ON -G Ninja ..

```

This is the error message:

```prolog
CMake Error at cmake/port/Windows.cmake:36 (message):
  Cannot file /bin/zlib*.dll

```

Obviously, one has to tell cmake where to find the prerequisites. Did I miss something?

```prolog
W64 (~) 553_> cd mingw64/bin/
W64 (bin) 554_> ls
bsdcat.exe bsdtar.exe cjpeg.exe jpegtran.exe libcrypto-1_1-x64.dll libgcc_s_seh-1.dll libjpeg-9.dll libpcreposix-0.dll libwinpthread-1.dll openssl.exe pcregrep.exe rdjpgcom.exe zlib1.dll
bsdcpio.exe c_rehash djpeg.exe libarchive-13.dll libffi-7.dll libgmp-10.dll libpcre-1.dll libssl-1_1-x64.dll libyaml-0-2.dll pcre-config pcretest.exe wrjpgcom.exe

```

---

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [March 11, 2022, 12:08pm UTC](https://swi-prolog.discourse.group/t/find-swipl/5109/12 "2022-03-11T12:08:46Z")

</div>

It looks promising. From the crosscompilation:

```prolog
-- Finding default package generator
-- Setup for packaging with NSIS64
-- Configuring done
-- Generating done

```

Then ninja, then cpack.

```prolog
matthias@DESKTOP-A2T8IFC:~/swipl-devel/build.win64$ cpack
CPack: Create package using NSIS64
CPack: Install projects
CPack: - Install project: SWI-Prolog []

```

Despite the above, the exe file with the installer is still (!) a 32-bit-application. Anyway, with an extra NSIS command, SetRegView 64, we can write into the 64 bit registry.
