Getting there slowly… I discovered some interesting behavior, MSYS2-specific. A bunch of relevant dlls are in /mingw64/bin, e.g. zlib1.dll. So I wanted to add this to the DLL search path.
Matthias@DESKTOP-A2T8IFC MINGW64 ~/swipl-devel/build.mingw64/src
$ ./swipl -g "win_add_dll_directory('/mingw64/bin')" -g "use_module(library(archive))" -g halt
(works)
Matthias@DESKTOP-A2T8IFC MINGW64 ~/swipl-devel/build.mingw64/src
$ ./swipl -g "win_add_dll_directory('c:/msys64/mingw64/bin')" -g "use_module(library(archive))" -g halt
(works)
The thing is that MSYS2 bash translates /mingw64 to c:/msys64/mingw64/bin. Note that “c:/msys64” is mounted on “/”.
Matthias@DESKTOP-A2T8IFC MINGW64 ~/swipl-devel/build.mingw64/src
$ mount
C:/msys64 on / type ntfs (binary,noacl,auto)
C:/msys64/usr/bin on /bin type ntfs (binary,noacl,auto)
C: on /c type ntfs (binary,noacl,posix=0,user,noumount,auto)
This does not work from within swipl, and below one can see why not:
$ ./swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.5.12-23-g9c00eb16e-DIRTY)
?- win_add_dll_directory('/mingw64/bin'), use_module(library(archive)).
ERROR: c:/msys64/home/matthias/swipl-devel/build.mingw64/home/library/archive.pl:111:
ERROR: c:/msys64/home/matthias/swipl-devel/build.mingw64/home/library/archive.pl:111: Initialization goal raised exception:
ERROR: Das angegebene Modul wurde nicht gefunden.
etc.
?- absolute_file_name('/mingw64/bin', F).
F = 'c:/mingw64/bin'.
?- halt.
Technically, the response of absolute_file_name/2 is wrong, because the msys64 is missing. I guess this would be difficult to solve this from within swipl, although there might be a support for this from MSYS2, I don’t know. For a quick and partial fix, I think users wouldn’t mind a message if the directory of win_add_dll_directory(Dir) is not an absolute path, as well as a warning if it does not exist on the file system. Do you agree?
Just for the files, with the correct path, module import is working fine:
Matthias@DESKTOP-A2T8IFC MINGW64 ~/swipl-devel/build.mingw64/src
$ ./swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.5.12-23-g9c00eb16e-DIRTY)
?- win_add_dll_directory('c:/msys64/mingw64/bin').
true.
?- use_module(library(archive)).
true.