# Current status of SWI-Prolog with RocksDB packages installed using MSYS2

**URL:** <https://swi-prolog.discourse.group/t/current-status-of-swi-prolog-with-rocksdb-packages-installed-using-msys2/6229>\
**Category:** Split Topic\
**Created:** [February 14, 2023, 8:31am UTC](https://swi-prolog.discourse.group/t/current-status-of-swi-prolog-with-rocksdb-packages-installed-using-msys2/6229 "2023-02-14T08:31:51Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [February 19, 2023, 9:58am UTC](https://swi-prolog.discourse.group/t/current-status-of-swi-prolog-with-rocksdb-packages-installed-using-msys2/6229/7 "2023-02-19T09:58:26Z")

</div>

This topic seems to have died 🤔

In doing some leg work to get RocksDB working with SWI-Prolog via MSYS2 using Jan’s two repos

> **[GitHub - JanWielemaker/rocksdb: SWI-Prolog interface for RocksDB](https://github.com/JanWielemaker/rocksdb)**
>
> SWI-Prolog interface for RocksDB. Contribute to JanWielemaker/rocksdb development by creating an account on GitHub.

> **[GitHub - JanWielemaker/rocks-predicates: Put predicates into a RocksDB database](https://github.com/JanWielemaker/rocks-predicates)**
>
> Put predicates into a RocksDB database. Contribute to JanWielemaker/rocks-predicates development by creating an account on GitHub.

did this as an exercise to learn more

> [@SWI-Prolog Foreign Language Interface (MSYS2 - DLL)](https://swi-prolog.discourse.group/t/swi-prolog-foreign-language-interface-msys2/6268):
>
> On Windows Install MSYS2 See [MSYS2](https://www.msys2.org/) for details. MSYS2 creates several interactive shells [image] For these instructions only two shells will be used. [image] MSYS2 MSYS - For building a Dynamic Link Library (DLL) with a C toolchain. [image] MYSY2 MINGW64 - For starting SWI-Prolog. Create DLL Using MSYS2 MSYS [image] Install toolchain $ pacman -S mingw-w64-x86\_64-toolchain Change directory as desired, e.g. $ cd “~\Example” File: add.c #include \<SWI-Prolog.h\> static foreign\_t p…

As many of you know but I just discovered, SWI-Prolog interface for RocksDB is built as a static library and not a DLL or shared object. ([ref](https://github.com/JanWielemaker/rocksdb/blob/7424e8a805a21f311956879b2a2d5ba116e7fb52/Makefile#L30)) The norm seems to be that a DLL or shared object is preferred and a static library is the expectation. ([ref](https://www.swi-prolog.org/pldoc/man?section=foreign-linking-options))

As Jan W. noted [here](https://swi-prolog.discourse.group/t/pack-rocksdb-c-issue/1606/2)

> - The static lib is not compiled with `-fPIC` and can thus not be used to create a shared object.

but then @mgondan1 notes here

> I have recompiled rocksdb with RTTI and PIC on msys (RTTI was already set to on, PIC needed an extra run), so the main challenge is to remove it from the prolog pack

Any further updates? Care to share the MSYS2 build steps? Why the need to `remove it from the prolog pack`?

@peter.ludemann does note the make for Linux which which sets `-fPIC` `USE_RTTI=`

> make -C $SRC/rocksdb SUBMODULE\_UPDATE= SWIPL=$BUILD\_DIR/src/swipl PACKSODIR=/tmp/rocksdb-so SOEXT=so CFLAGS=“-fPIC -pthread -I$SRC/swipl-devel/src -I$SRC/swipl-devel/src/os -I$SRC/swipl-devel/packages/cpp” plugin check

which is helpful.

@paule32 has provided a GItHub repo that I need to look at in more detail.

Thanks to all involved.

* * *

Side note

For me this is just a stepping stone to

1. Build SWI-Prolog using Microsoft Visual Studio ([ref](https://swi-prolog.discourse.group/t/build-swi-prolog-using-microsoft-visual-studio/1086))
2. Add the RocskDB functionality for the Windows build using Microsoft Visual Studio

---

_[View the full topic](https://swi-prolog.discourse.group/t/current-status-of-swi-prolog-with-rocksdb-packages-installed-using-msys2/6229)._
