Find swipl

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

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

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.

Thanks. It does seem to work :slight_smile:

Found it!

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\SWI\Prolog

Whatever this WOW6432Node is…

Thanks!

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.

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.

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.

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

It seems as if the architecture can be changed easily,

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)

2 Likes

(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:

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:

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?

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

It looks promising. From the crosscompilation:

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

Then ninja, then cpack.

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.