# Ann: SWI-Prolog 9.1.16

**URL:** <https://swi-prolog.discourse.group/t/ann-swi-prolog-9-1-16/6862>\
**Category:** Releases\
**Created:** [September 25, 2023, 7:33pm UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-9-1-16/6862 "2023-09-25T19:33:19Z")\
**Posts on this page:** 12\
**Page:** 1

<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:** [September 25, 2023, 7:33pm UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-9-1-16/6862/1 "2023-09-25T19:33:19Z")

</div>

Dear SWI-Prolog user,

SWI-Prolog 9.1.16 is ready for download. Most of the work is on  
(language) interfaces and portability. Highlights:

- Several changes and enhancements to the Janus Python interface.

- More work on the C++ interface by @peter.ludemann

- Updated JPL .class files to Java 8 as the latest OpenJDK no longer  
handles version 7.

- Several performance enhancements to arithmetic.

- Fixed a memory leak in PL\_put\_term\_from\_chars() for numbers.

# SWI-Prolog Changelog since version 9.1.15

- PORT: Partial work to allow MSVC build under Conda. This patch works  
around issues for CMake FindThreads.cmake. It also explicitly enables  
MSVC `/MD` to compile the packages if threading is enabled.

- BUILD: Runtime configuration during boot for Windows As, on Windows,  
we install all DLLs in the same directory we do not need to add  
the package bin dirs to the foreign search path. But, we must use  
prolog\_to\_os\_filename/2 to ensure proper handling of the search based  
on the executable.

- FIXED: #1197 function cmpr failing for negative values.

- FIXED: #1097 ctrl-C in read causes exit from REPL Fix consists of  
two parts. (1) if something (libedit) already set the stream error  
condition, make S\_\_fillbuf() return with an error immediately and  
(2) do not abort the main query loop if we get an abort request.

- DOC: additions and cleanup wrap\_predicate/4, pack\_install/1, handling  
blobs and streams from foreign code, returning from foreign predicates.

- ENHANCED: Allow interrupts during evalExpression()

- PORT: Make new stuff work again using MSVC

- ENHANCED: dark theme arithmetic used blue on black. [no ci]

- PERFORMANCE: Add shortcut to PL\_unify\_number() Add a shortcut for  
the typical case where the number is a small integer, the target is  
a variable and we are not short on stack space.

- PERFORMANCE: Simplify clearNumber() Notably improves performance for  
float arithmetic.

- FIXED: Memory leak in PL\_put\_term\_from\_chars() fast route. This  
function implements a fast route for integers and rationals and leaked  
the GMP/LibBF object for rationals and large integers.

- ENHANCED: PL\_get\_float() to raise a float overflow on too large  
rational.

- BUILD: Added scripts/configure This script is used for a long time  
to maintain multiple versions under the same source tree. See script  
for details. [no ci]

- PORT: Work around broken MacOS versions lacking `<term.h>` Reported  
by Matthias Gondan after failing build for CRAN

- FIXED: PL\_get\_nchars() and friends `CVT_INTEGER` handling Broken  
in 2ac1553770ac1a9d6753b8b6e72ac2028815a028

- ADDED: PL\_get\_nchars(): CVT\_XINTEGER Allow converting numbers to  
hexadecimal strings.

- DOC: library(occurs) [no ci]

## Package cpp

- ENHANCEMENT: added PlAcquireStream

- ENHANCED: AtomMap utility

- DOC: blobs and exceptions

- ENHANCED: std::string instead of char\* in some calls (no code change  
needed) - Can add char\* interface if needed for performance (unlikely)  
PlTerm(term\_t) constructor is public, for consistency with PlAtom

## Package jpl

- UPDATED: Java standards from 7 to 8. Support for 7 is dropped from  
latest OpenJDK releases and 7 is officially EOL for a while.

## Package swipy

- DOC: Handling Undefined

- ADDED: Class Undefined to deal with WFS undefined results.

- MODIFIED: Renamed `status` and `truth_vals` to `truth` As decided in  
Janus meeting, September 20.

- TEST: Install XSB test data if installation includes the tests

- BUILD: Starting a pyproject.toml

- DOC: Document handling virtual environments.

- ADDED: Support Python virtual environments

- ADDED: Pass instances of class Enum as name (atom).

- FIXED: Avoid recursive errors crashing while janus.py is being loaded.  
It seems we cannot call certain APIs while processing an error.

- ADDED: Map Prolog rational numbers to Python `fractions.Fraction()`.

- ENHANCED: Use hexadecimal conversion for bigints.

- DOC: Included references

- COMPAT: Sync py\_func/3,4 and py\_dot/4,5. Updated docs.

- MODIFIED: Sync XSB view with current agreement. - pyfunc/3-5,  
pydot/4,5 renamed to py\_func/3-5 and py\_dot/4,5. - Deleted  
free\_python\_object/1 (=py\_free/1)

- MODIFIED: Rules when py\_object(true) is effective

- MODIFIED: Use eval(Term) to evaluate Python expressions inline.

- MODIFIED: Prolog representation of Python sets to use py\_set(List)  
Was pySet(List).

---

<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:** [September 26, 2023, 11:09am UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-9-1-16/6862/2 "2023-09-26T11:09:04Z")

</div>

Under MSYS2-ucrt64, I get:

```prolog
$ cmake ..
$ ninja
ninja: error: 'C:/msys64/ucrt64/lib/libpython3.dll.a', needed by 'src/janus.dll', missing and no known rule to make it

```

There is a /ucrt64/bin/libpython3.10.dll, as well as a /ucrt64/lib/libpython3.10.dll.a, which is correctly reported by `message("${Python_LIBRARIES}")` in the CMakeFile.

Workaround is `cmake .. -DSWIPL_PACKAGES_PYTHON=OFF`.

---

<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:** [September 26, 2023, 11:36am UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-9-1-16/6862/3 "2023-09-26T11:36:14Z")

</div>

Under rtools31-ucrt64, I get:

```prolog
$ PATH=/x86_64-w64-mingw32.static.posix/bin:$PATH cmake .. -DSWIPL_PACKAGES_PYTHON=OFF -DSWIPL_PACKAGES_X=OFF -DINSTALL_DOCUMENTATION=OFF
$ PATH=/x86_64-w64-mingw32.static.posix/bin:$PATH make
...
[81%] Building C object packages/ssl/CMakeFiles/plugin_crypto4pl.dir/crypto4pl.c.obj
In file included from C:/Users/matthias/Documents/swipl-devel/packages/ssl/crypto4pl.c:55:
C:/Users/matthias/Documents/swipl-devel/packages/ssl/cryptolib.c:54:1: error: static declaration of 'EVP_MD_CTX_free' follows non-static declaration
   54 | EVP_MD_CTX_free(EVP_MD_CTX *ctx)

```

Ahh, very vaguely, I remember this from months or even years ago. What was it…? I’ll search for a fix.

Solution: MINGW\_ROOT must be defined,

```prolog
PATH=/x86_64-w64-mingw32.static.posix/bin:$PATH cmake .. -DSWIPL_PACKAGES_PYTHON=OFF -DSWIPL_PACKAGES_X=OFF -DINSTALL_DOCUMENTATION=OFF -DMINGW_ROOT=/x86_64-w64-mingw32.static.posix/bin

```

---

<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:** [September 26, 2023, 7:44pm UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-9-1-16/6862/4 "2023-09-26T19:44:44Z")

</div>

This change in swipy/CMakeLists.txt made the compiler happy.

```prolog
swipl_plugin(
    janus
    MODULE janus
    C_SOURCES janus/janus.c
    C_LIBS ${Python_LIBRARIES} ****
    C_INCLUDE_DIR ${Python_INCLUDE_DIRS} ****
    PL_LIBS janus/janus.pl
    PL_LIB_SUBDIR python
    PL_LIBS ${PYTHON_FILES})

```

I hope it is of any help. System is MSYS2, aka. MinGW.

---

<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:** [September 27, 2023, 11:49am UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-9-1-16/6862/5 "2023-09-27T11:49:10Z")

</div>

> [@mgondan1](#):
>
> ```prolog
> C_LIBS ${Python_LIBRARIES} ****
> C_INCLUDE_DIR ${Python_INCLUDE_DIRS} ****
> 
> ```

I think the problem is that on Windows we use the generic `python3.dll`, but we do so without testing it exists. It is part of the Python binary installation, but apparently not of the MSYS2 version. Added a check.

---

<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:** [September 27, 2023, 11:51am UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-9-1-16/6862/6 "2023-09-27T11:51:40Z")

</div>

> [@mgondan1](#):
>
> Ahh, very vaguely, I remember this from months or even years ago. What was it…? I’ll search for a fix.
> 
> Solution: MINGW\_ROOT must be defined,

That sounds weird. Looks like it is picking up a wrong version of the headers? MINGW\_ROOT points at a directory that has all the MinGW depedencies installed. That is supposed not to be a `bin` dir, but the dir above `bin`, `lib` and `include`.

---

<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:** [September 27, 2023, 12:59pm UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-9-1-16/6862/7 "2023-09-27T12:59:41Z")

</div>

I am not entirely sure what a line such as

`AC_CHECK_FUNCS(EVP_MD_CTX_free OPENSSL_zalloc)`

actually does, but if it does the same as `check_symbol_exists(...)`, then it compiles and links a little program with a pointer to, e.g., `EVP_MD_CTX_free`. And the linker needs zlib.h under MinGW, which is only given if MINGW\_ROOT has been defined.

```prolog
  if(WIN32)
    set(OPENSSL_OS_LIBS ws2_32.lib gdi32.lib crypt32.lib)
    if(MINGW_ROOT)
      list(APPEND OPENSSL_OS_LIBS z.lib)
    endif()

```

It’s working, no need to change things here.

---

<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:** [September 27, 2023, 1:43pm UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-9-1-16/6862/8 "2023-09-27T13:43:22Z")

</div>

> [@mgondan1](#):
>
> It’s working, no need to change things here.

But it works for the wrong reason ☹ Seems the condition is part of the MSVC porting work where zlib.lib is used from vcpkg and, called zlib1.lib and apparently not required to link OpenSSL. I think we must make this unconditional again and use `${ZLIB_LIBRARIES}`

Finding the right conditions for differences in the configuration is quite a challenge ☹

**edit** : Pushed 86bf1a111390f7457e77f930fd5241999c2de472 to address this. Works for me using MinGW as well as MSVC. This code is only used on Windows, so other platforms are not affected.

---

<div class="post-metadata">

**Author:** ![joseph-vidal-rosset](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/joseph-vidal-rosset/32/2594_2.png) [@joseph-vidal-rosset](https://swi-prolog.discourse.group/u/joseph-vidal-rosset)\
**Post date:** [September 27, 2023, 7:03pm UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-9-1-16/6862/10 "2023-09-27T19:03:16Z")

</div>

joseph@mx:~$ swipl --version  
SWI-Prolog version 9.1.16 for x86\_64-linux

Many thanks for this wonderful job !

---

<div class="post-metadata">

**Author:** ![anon419083](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@anon419083](https://swi-prolog.discourse.group/u/anon419083)\
**Post date:** [September 29, 2023, 4:05pm UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-9-1-16/6862/11 "2023-09-29T16:05:10Z")

</div>

When one installs swi-prolog via macports python’s latest release is also one of the dependencies, right? So one installs both swipl and python311 plus a bunch of other things. I was surprised to see that you don’t have to install it manually if you run “port install swi-prolog-devel”

PS: maybe the other thread with the announcement was more appropriate. This one is for arithmetics

---

<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:** [September 30, 2023, 4:07pm UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-9-1-16/6862/12 "2023-09-30T16:07:40Z")

</div>

> [@anon419083](#):
>
> I was surprised to see that you don’t have to install it manually if you run “port install swi-prolog-devel”

Macports is fairly relaxed about big dependencies. As most Macports installations already have Python installed anyway, it is not that big. This is quit different from Debian that tries to keep packages small, such that you can configure a minimal system with exactly the stuff you need and as little as possible extras.

So, yes, Macports gives you a pretty much complete SWI-Prolog, possibly with some stuff you might not have wanted …

---

<div class="post-metadata">

**Author:** ![anon419083](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@anon419083](https://swi-prolog.discourse.group/u/anon419083)\
**Post date:** [September 30, 2023, 4:41pm UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-9-1-16/6862/13 "2023-09-30T16:41:41Z")

</div>

Thanx a lot for the explanation. Regarding stuff one doesn’t want…well, you know if you put yourself in someone else’s hands or judgements…you have to accept what’s included in the package so to say. Of course whether this is fair or not remains an open issue. At least for me. But I’m more interested in what comes next than in brooding about the past (although it is meaningful to do so). Best things

PS: maybe “reflecting” is better than “brooding” which at least to my ears seems to have a negative connotation
