Building swipl on Win64, MSYS2 (cmake, make, make install)

Dear list,

Today I tried to build swipl on a fresh MSYS2 installation for Win64. I got quite far actually:

The usual pacman stuff

  • pacman -Syu, then pacman -Su git, cmake, gcc, make, zlib-devel, ncurses-devel, gmp-devel, libedit-devel, openssl-devel, libarchive-devel, base-devel, libcrypt-devel

Then

  • cd swipl-devel
  • mkdir build
  • cmake …
  • make
  • make install
  • swipl

During compilation, an error message appeared, stating that ftello64, fseek64 etc. were not found. I made a little change around line 20 in src/minizip/ioapi.c

#if defined(__APPLE__) || defined(IOAPI_NO_64)

to

#if defined(__APPLE__) || defined(IOAPI_NO_64) || (defined(__MSYS__) && defined(__x86_64))

This made the compilation work, but I am very unsure if it is correct - it would obviously be better to have IOAPI_NO_64 set properly, whatever this is. The compilation reached 100%, although there were two blocks of red error messages, some issues with shared libraries that couldn’t be loaded.

ERROR: /home/Matthias/swipl-devel/build/home/library/archive.pl:96:
ERROR:    /home/Matthias/swipl-devel/build/home/library/archive.pl:96: Initialization goal raised exception:
ERROR:    '$open_shared_object'/3: No such file or directory
ERROR: /home/Matthias/swipl-devel/build/home/library/prolog_pack.pl:726:
ERROR:    Exported procedure archive:archive_open_entry/2 is not defined
ERROR: /home/Matthias/swipl-devel/build/home/library/prolog_pack.pl:726:
ERROR:    Exported procedure archive:archive_next_header/2 is not defined
ERROR: /home/Matthias/swipl-devel/build/home/library/prolog_pack.pl:726:
ERROR:    Exported procedure archive:archive_close/1 is not defined
ERROR: /home/Matthias/swipl-devel/build/home/library/prolog_pack.pl:726:
ERROR:    Exported procedure archive:archive_set_header_property/2 is not defined

And a second one related to http

ERROR: /home/Matthias/swipl-devel/build/home/library/crypto.pl:72:
ERROR:    /home/Matthias/swipl-devel/build/home/library/crypto.pl:72: Initialization goal raised exception:
ERROR:    '$open_shared_object'/3: No such file or directory
ERROR: /home/Matthias/swipl-devel/build/home/library/ssl.pl:67:
ERROR:    Exported procedure crypto:rsa_private_decrypt/4 is not defined
(I skipped the rest)

After make install, I had to copy msys-swipl-8.dll to a folder where it could be found by the system.

So, there seem to be only minor issues with finding dlls, and the thing with the 64-bit fseek.

Best wishes,

Matthias

Thanks. Pushed a patch that uses CMake to figure out whether or not to use the 64 bit file functions. Note that it doesn’t matter much. We only use this stuff to read the Prolog startup file.

The reported errors are dependency issues that cause some of the documentation to be built too soon. It is harmless (but I’m still hoping it is fixable). In fact, I thought I’d fixed it. Did you use the release tar or git?

What is msys-swipl-8.dll? Is that a dedicated runtime library or so?

Dear Jan, I used the current git, and now I updated for a test:

  • 64 bit file functions: works fine now.
  • the errors while building the documentation are still there: I have put the filename into the PL_error call (pl-load.c, line 226 -> return PL_error(NULL, 0, fn, ERR_SHARED_OBJ_OP, [etc]))
ERROR: /home/Matthias/swipl-devel/build/home/library/crypto.pl:72:
ERROR:    /home/Matthias/swipl-devel/build/home/library/crypto.pl:72: Initialization goal raised exception:
ERROR:    '$open_shared_object'/3: No such file or directory (crypto4pl)
ERROR: /home/Matthias/swipl-devel/build/home/library/ssl.pl:67:
ERROR:    Exported procedure crypto:rsa_private_decrypt/4 is not defined
ERROR: /home/Matthias/swipl-devel/build/home/library/ssl.pl:67:

Same issue for ssl4pl and (a bit earlier) archive4pl. As you mention, they are harmless during the build process, so everything continues until 100%.

  • make install: the msys-swipl-8.dll is probably the same as libswipl-8.1.28.so in linux (?)
  • Invoking swipl works.
  • Then I wanted to install a pack: pack_install(rserve_client)
% Contacting server at https://www.swi-prolog.org/pack/query ...
ERROR: SSL(1416F086) tls_process_server_certificate: certificate verify failed
ERROR: In:
ERROR:   [21] throw(error(ssl_error('1416F086','SSL routines',tls_process_server_certificate,'certificate verify failed'),_24368))
ERROR:   [20] '<meta-call>'(http_open:(...,...)) <foreign>
ERROR:   [19] catch(http:http_protocol_hook(https,...,<stream>(0x600162950,0x6003c2170),_24468,...),error(ssl_error('1416F086','SSL routines',tls_process_server_certificate,'certificate verify failed'),_24476),http_open:(...,...)) at /usr/local/lib/swipl/boot/init.pl:483
ERROR:   [18] http_open:try_http_proxy(direct,[uri('https://www.swi-prolog.org/pack/query'),...|...],_24532,[post(...),...]) at /usr/local/lib/swipl/library/http/http_open.pl:439
ERROR:   [17] http_open:http_open('https://www.swi-prolog.org/pack/query',_24598,prolog_pack:[...|...]) at /usr/local/lib/swipl/library/http/http_open.pl:393
ERROR:   [16] <meta call>
ERROR:   [15] '$sig_atomic'(prolog_pack:http_open('https://www.swi-prolog.org/pack/query',_24672,...)) <foreign>
ERROR:   [14] setup_call_catcher_cleanup(prolog_pack:http_open('https://www.swi-prolog.org/pack/query',_24716,...),prolog_pack:read_reply(_24728,_24730,_24732),_24702,prolog_pack:close(_24742)) at /usr/local/lib/swipl/boot/init.pl:565
ERROR:   [13] setup_call_cleanup(prolog_pack:http_open('https://www.swi-prolog.org/pack/query',_24782,...),prolog_pack:read_reply(_24794,_24796,_24798),prolog_pack:close(_24808)) at /usr/local/lib/swipl/boot/init.pl:569
ERROR:   [12] prolog_pack:query_pack_server(locate(real),_24840,[]) at /usr/local/lib/swipl/library/prolog_pack.pl:1777
ERROR:   [11] prolog_pack:pack_default_options(real,real,[],_24882) at /usr/local/lib/swipl/library/prolog_pack.pl:516
ERROR:   [10] prolog_pack:pack_install(real) at /usr/local/lib/swipl/library/prolog_pack.pl:457
ERROR:    [9] <user>
   Exception: (21) throw(error(ssl_error('1416F086', 'SSL routines', tls_process_server_certificate, 'certificate verify failed'), _16900)) ? abort

Connectivity with R is actually the main motivation behind this exercise. Thank you for consideration. It is very much appreciated, given that the build process under windows is not among the top priorities of the project, as far as I know.

With best wishes,

Matthias

Dear Jan,

After today’s git pull in MSYS2 (Win64): The error messages related to crypto4pl and ssl4pl have disappeared. FWIW: The error related to archive4pl is still there. This is the screen dump of my “make” under MSYS2. Please note that I have put a little line in PL_dlopen that prints the file name of the shared library that is to be loaded, therefore, the extra lines in the output. You can see that the path for archive2pl is not being expanded:

[ 81%] Generating lib/prologpack.tex
PL_dlopen: /home/Matthias/swipl-devel/build/packages/clib/readutil.dll
PL_dlopen: /home/Matthias/swipl-devel/build/packages/clib/uri.dll
PL_dlopen: /home/Matthias/swipl-devel/build/packages/sgml/sgml2pl.dll
PL_dlopen: /home/Matthias/swipl-devel/build/packages/http/http_stream.dll
PL_dlopen: /home/Matthias/swipl-devel/build/packages/clib/files.dll
PL_dlopen: /home/Matthias/swipl-devel/build/packages/nlp/porter_stem.dll
PL_dlopen: /home/Matthias/swipl-devel/build/packages/clib/socket.dll
PL_dlopen: /home/Matthias/swipl-devel/build/packages/clib/process.dll
PL_dlopen: /home/Matthias/swipl-devel/build/packages/clib/memfile.dll
PL_dlopen: /home/Matthias/swipl-devel/build/packages/http/json.dll
PL_dlopen: archive4pl
ERROR: /home/Matthias/swipl-devel/build/home/library/archive.pl:96:
ERROR:    /home/Matthias/swipl-devel/build/home/library/archive.pl:96: Initialization goal raised exception:
ERROR:    '$open_shared_object'/3: No such file or directory (archive4pl)
ERROR: /home/Matthias/swipl-devel/build/home/library/prolog_pack.pl:726:
ERROR:    Exported procedure archive:archive_open_entry/2 is not defined

Best regards, and, as always, thanks for this great software.

Matthias

1 Like

Thanks for testing. I now know how to get rid of these, so I pushed a fix. Although harmless, a clean build looks so much better :slight_smile:

The lack of expansion is because Prolog cannot find the dll. It first tries to find the dll and loads it using an absolute path, so it knows it has the right one. If that fails it tries the plain dll name, hoping the OS can find it.

1 Like

Works. Thanks!