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

This works, thank you very much. :clap:


When I orginally did this I did not follow the insturctions correctly and entered y for Yes when asked to build SWI-Prolog RocksDB package which resulted in an error.

pack_install(rocksdb). resulted in ERROR: Unknown platform!

What was interesting was that the location of the SWI-Prolog packages for MSYS2 were /c/users/groot/appdata/local/swi-prolog/pack/rocksdb (which is a Windows directory and not a MSYS2 specific directory), I would have expected a subdirectory of C:\msys64\home\groot (which is a MSYS2 specific directory) which in MSYS2 would be ~.


Details (Click triangle to expand)

Using MSYS2

image

start

image

Change to working directory

Groot@Galaxy MINGW64 ~
$ cd ~/Projects/SWI-Prolog with RocksDB

Update SWI-Prolog and RocksDB packages using pacman

Groot@Galaxy MINGW64 ~/Projects/SWI-Prolog with RocksDB
$ pacman -S mingw-w64-x86_64-rocksdb mingw-w64-x86_64-swi-prolog
Click triangle for console ouptut
warning: mingw-w64-x86_64-rocksdb-7.9.2-1 is up to date -- reinstalling
warning: mingw-w64-x86_64-swi-prolog-9.0.4-1 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Packages (2) mingw-w64-x86_64-rocksdb-7.9.2-1  mingw-w64-x86_64-swi-prolog-9.0.4-1

Total Installed Size:  55.42 MiB
Net Upgrade Size:       0.00 MiB

:: Proceed with installation? [Y/n] Y
(2/2) checking keys in keyring                                                                                                                                     [####################################################################################################] 100%
(2/2) checking package integrity                                                                                                                                   [####################################################################################################] 100%
(2/2) loading package files                                                                                                                                        [####################################################################################################] 100%
(2/2) checking for file conflicts                                                                                                                                  [####################################################################################################] 100%
(2/2) checking available disk space                                                                                                                                [####################################################################################################] 100%
:: Processing package changes...
(1/2) reinstalling mingw-w64-x86_64-rocksdb                                                                                                                        [####################################################################################################] 100%
(2/2) reinstalling mingw-w64-x86_64-swi-prolog                                                                                                                     [####################################################################################################] 100%

Verify installation directory of SWI-Prolog

Groot@Galaxy MINGW64 ~/Projects/SWI-Prolog with RocksDB
$ which swipl
/mingw64/bin/swipl

Verify that SWI-Prolog runs

Groot@Galaxy MINGW64 ~/Projects/SWI-Prolog with RocksDB
$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 9.0.4)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

1 ?-

Uninstall SWI-Prolog RocksDB package.

1 ?- pack_remove(rocksdb).
% Removing 'c:/users/groot/appdata/local/swi-prolog/pack/rocksdb' and contents
true.

Install SWi-Prolog RocksDB package.

2 ?- pack_install(rocksdb).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
Install rocksdb@0.12.0 from GIT at https://github.com/JanWielemaker/rocksdb.git Y/n? Y
% Cloning into '/c/users/groot/appdata/local/swi-prolog/pack/rocksdb'...
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% "rocksdb.git" was downloaded 5 times
Package:                rocksdb
Title:                  SWI-Prolog interface to RocksDB
Installed version:      0.12.0
Author:                 Jan Wielemaker <jan@swi-prolog.org>
Maintainer:             Jan Wielemaker <jan@swi-prolog.org>
Packager:               Jan Wielemaker <jan@swi-prolog.org>
Home page:              https://github.com/JanWielemaker/rocksdb
Download URL:           https://github.com/JanWielemaker/rocksdb.git
Run post installation scripts for pack "rocksdb" Y/n?
ERROR: Submodule 'rocksdb' (https://github.com/facebook/rocksdb) registered for path 'rocksdb'
ERROR: Cloning into '/c/users/groot/appdata/local/swi-prolog/pack/rocksdb/rocksdb'...
ERROR: Unknown platform!
ERROR: Unknown platform!
Click triangle for rest of ouptut
ERROR: In file included from ./cache/lru_cache.h:14,
ERROR:                  from cache/cache.cc:12:
ERROR: ./cache/sharded_cache.h:125:11: error: 'port' does not name a type
ERROR:   125 |   mutable port::Mutex capacity_mutex_;
ERROR:       |           ^~~~
ERROR: In file included from ./cache/lru_cache.h:20:
ERROR: ./util/distributed_mutex.h:43:16: error: 'port' does not name a type
ERROR:    43 | using DMutex = port::Mutex;
ERROR:       |                ^~~~
ERROR: ./util/distributed_mutex.h:44:25: error: 'lock_guard' in namespace 'std' does not name a template type
ERROR:    44 | using DMutexLock = std::lock_guard<DMutex>;
ERROR:       |                         ^~~~~~~~~~
ERROR: ./util/distributed_mutex.h:1:1: note: 'std::lock_guard' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
ERROR:   +++ |+#include <mutex>
ERROR:     1 | //  Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
ERROR: ./cache/lru_cache.h:334:33: error: expected initializer before 'LRUCacheShard'
ERROR:   334 | class ALIGN_AS(CACHE_LINE_SIZE) LRUCacheShard final : public CacheShard {
ERROR:       |                                 ^~~~~~~~~~~~~
ERROR: ./cache/lru_cache.h:555:3: error: 'LRUCacheShard' does not name a type; did you mean 'CacheShard'?
ERROR:   555 |   LRUCacheShard* shards_ = nullptr;
ERROR:       |   ^~~~~~~~~~~~~
ERROR:       |   CacheShard
ERROR: ./cache/lru_cache.h:564:34: error: 'LRUCacheShard' in namespace 'rocksdb::lru_cache' does not name a type; did you mean 'LRUCache'?
ERROR:   564 | using LRUCacheShard = lru_cache::LRUCacheShard;
ERROR:       |                                  ^~~~~~~~~~~~~
ERROR:       |                                  LRUCache
ERROR: In file included from ./util/coding.h:24,
ERROR:                  from ./cache/cache_reservation_manager.h:24,
ERROR:                  from cache/cache_reservation_manager.cc:9:
ERROR: ./util/coding_lean.h: In function 'void rocksdb::EncodeFixed16(char*, uint16_t)':
ERROR: ./util/coding_lean.h:25:7: error: 'port' has not been declared
ERROR:    25 |   if (port::kLittleEndian) {
ERROR:       |       ^~~~
ERROR: ./util/coding_lean.h: In function 'void rocksdb::EncodeFixed32(char*, uint32_t)':
ERROR: ./util/coding_lean.h:34:7: error: 'port' has not been declared
ERROR:    34 |   if (port::kLittleEndian) {
ERROR:       |       ^~~~
ERROR: ./util/coding_lean.h: In function 'void rocksdb::EncodeFixed64(char*, uint64_t)':
ERROR: ./util/coding_lean.h:45:7: error: 'port' has not been declared
ERROR:    45 |   if (port::kLittleEndian) {
ERROR:       |       ^~~~
ERROR: ./util/coding_lean.h: In function 'uint16_t rocksdb::DecodeFixed16(const char*)':
ERROR: ./util/coding_lean.h:63:7: error: 'port' has not been declared
ERROR:    63 |   if (port::kLittleEndian) {
ERROR:       |       ^~~~
ERROR: ./util/coding_lean.h: In function 'uint32_t rocksdb::DecodeFixed32(const char*)':
ERROR: ./util/coding_lean.h:75:7: error: 'port' has not been declared
ERROR:    75 |   if (port::kLittleEndian) {
ERROR:       |       ^~~~
ERROR: ./util/coding_lean.h: In function 'uint64_t rocksdb::DecodeFixed64(const char*)':
ERROR: ./util/coding_lean.h:89:7: error: 'port' has not been declared
ERROR:    89 |   if (port::kLittleEndian) {
ERROR:       |       ^~~~
ERROR: ./util/coding.h: In function 'void rocksdb::PutFixed16(std::string*, uint16_t)':
ERROR: ./util/coding.h:123:7: error: 'port' has not been declared
ERROR:   123 |   if (port::kLittleEndian) {
ERROR:       |       ^~~~
ERROR: ./util/coding.h: In function 'void rocksdb::PutFixed32(std::string*, uint32_t)':
ERROR: ./util/coding.h:134:7: error: 'port' has not been declared
ERROR:   134 |   if (port::kLittleEndian) {
ERROR:       |       ^~~~
ERROR: ./util/coding.h: In function 'void rocksdb::PutFixed64(std::string*, uint64_t)':
ERROR: ./util/coding.h:145:7: error: 'port' has not been declared
ERROR:   145 |   if (port::kLittleEndian) {
ERROR:       |       ^~~~
ERROR: make[1]: *** [Makefile:2529: cache/cache_reservation_manager.o] Error 1
ERROR: make[1]: *** Waiting for unfinished jobs....
ERROR: make[1]: *** [Makefile:2529: cache/cache.o] Error 1
ERROR: make: *** [Makefile:30: rocksdb/librocksdb.a] Error 2
% git submodule update --init rocksdb
% Submodule path 'rocksdb': checked out 'eb9a80fe1f18017b4d7f4084e8f2554f12234822'
% ROCKSDB_DISABLE_JEMALLOC=1 ROCKSDB_DISABLE_TCMALLOC=1 /usr/bin/make -j4 -C rocksdb static_lib EXTRA_CXXFLAGS=-fPIC EXTRA_CFLAGS=-fPIC USE_RTTI=1 DEBUG_LEVEL=0
% make[1]: Entering directory '/c/users/groot/appdata/local/swi-prolog/pack/rocksdb/rocksdb'
% $DEBUG_LEVEL is 0
% $DEBUG_LEVEL is 0
%   CC       cache/cache.o
%   CC       cache/cache_entry_roles.o
%   CC       cache/cache_key.o
%   CC       cache/cache_reservation_manager.o
% make[1]: Leaving directory '/c/users/groot/appdata/local/swi-prolog/pack/rocksdb/rocksdb'
ERROR: Process "process(c:/msys64/usr/bin/make.exe,[])": exit status: 2
ERROR: In:
ERROR:   [25] throw(error(process_error(...,...),_91686))
ERROR:   [21] build_tools:build_step(build,_91730{env:[...|...],git:true,inquiry:true,pack:rocksdb,pack_version:1,src_dir:'c:/users/groot/appdata/local/swi-prolog/pack/rocksdb',url:'https://github.com/JanWielemaker/rocksdb.git'},_91730{bin_dir:'c:/users/groot/appdata/local
/swi-prolog/pack/rocksdb',env:[...|...],git:true,inquiry:true,pack:rocksdb,pack_version:1,src_dir:'c:/users/groot/appdata/local/swi-prolog/pack/rocksdb',url:'https://github.com/JanWielemaker/rocksdb.git'}) at c:/msys64/mingw64/lib/swipl/library/build/tools.pl:110
ERROR:   [20] apply:foldl_([build,...|...],build_tools:build_step,_91730{env:[...|...],git:true,inquiry:true,pack:rocksdb,pack_version:1,src_dir:'c:/users/groot/appdata/local/swi-prolog/pack/rocksdb',url:'https://github.com/JanWielemaker/rocksdb.git'},_91842) at c:/msys64
/mingw64/lib/swipl/library/apply.pl:316
ERROR:   [16] build_tools:build_steps([[dependencies],...|...],'c:/users/groot/appdata/local/swi-prolog/pack/rocksdb',[pack_version(1),...|...]) at c:/msys64/mingw64/lib/swipl/library/build/tools.pl:103
ERROR:   [15] prolog_pack:post_install_foreign(rocksdb,'c:/users/groot/appdata/local/swi-prolog/pack/rocksdb','<garbage_collected>') at c:/msys64/mingw64/lib/swipl/library/prolog_pack.pl:1173
ERROR:   [14] prolog_pack:pack_post_install(rocksdb,'c:/users/groot/appdata/local/swi-prolog/pack/rocksdb',[git(true),...|...]) at c:/msys64/mingw64/lib/swipl/library/prolog_pack.pl:1111
ERROR:    [9] toplevel_call('<garbage_collected>') at c:/msys64/mingw64/lib/swipl/boot/toplevel.pl:1173
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
   Exception: (21) build_tools:build_step(build, _130{env:['PATH'='.;C:\\msys64\\mingw64\\bin;C:\\msys64\\usr\\local\\bin;C:\\msys64\\usr\\bin;C:\\msys64\\usr\\bin;C:\\Windows\\System32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.
0\\;C:\\msys64\\usr\\bin\\site_perl;C:\\msys64\\usr\\bin\\vendor_perl;C:\\msys64\\usr\\bin\\core_perl', 'SWIPL'='C:\\msys64\\mingw64\\lib\\swipl\\bin\\x64-win64\\swipl.exe', 'SWIPL_PACK_VERSION'=1, 'SWIPLVERSION'=90004, 'SWIHOME'='c:/msys64/mingw64/lib/swipl', ... = ...|
...], git:true, inquiry:true, pack:rocksdb, pack_version:1, src_dir:'c:/users/groot/appdata/local/swi-prolog/pack/rocksdb', url:'https://github.com/JanWielemaker/rocksdb.git'}, _6794) ?

I am not surprised by this result. A few years ago when I first started using SWI-Prolog packages, many that were not pure Prolog and relied on the OS in some form only worked for Linux, thus my journey into using WSL with SWI-Prolog to run such packages.


Answering with n for No this time.

Details (Click triangle to expand)
1 ?- pack_remove(rocksdb).
% Removing 'c:/users/groot/appdata/local/swi-prolog/pack/rocksdb' and contents
true.

2 ?- pack_install(rocksdb).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
Install rocksdb@0.12.0 from GIT at https://github.com/JanWielemaker/rocksdb.git Y/n?
% Cloning into '/c/users/groot/appdata/local/swi-prolog/pack/rocksdb'...
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% "rocksdb.git" was downloaded 7 times
Package:                rocksdb
Title:                  SWI-Prolog interface to RocksDB
Installed version:      0.12.0
Author:                 Jan Wielemaker <jan@swi-prolog.org>
Maintainer:             Jan Wielemaker <jan@swi-prolog.org>
Packager:               Jan Wielemaker <jan@swi-prolog.org>
Home page:              https://github.com/JanWielemaker/rocksdb
Download URL:           https://github.com/JanWielemaker/rocksdb.git
Run post installation scripts for pack "rocksdb" Y/n?   <===  Press n for No here.
false.

3 ?- halt.
Groot@Galaxy MINGW64 ~
$ cd "/c/Users/Groot/AppData/Local/swi-prolog/pack/rocksdb"

Groot@Galaxy MINGW64 /c/Users/Groot/AppData/Local/swi-prolog/pack/rocksdb
$ tree
.
├── Makefile
├── README.md
├── cpp
│   └── rocksdb4pl.cpp
├── demo
│   └── merge.pl
├── pack.pl
├── prolog
│   └── rocksdb.pl
├── rocksdb
└── test
    └── test_rocksdb.pl

5 directories, 7 files

Groot@Galaxy MINGW64 /c/Users/Groot/AppData/Local/swi-prolog/pack/rocksdb
$ g++ -shared -D__SWI_PROLOG__ -I/mingw64/lib/swipl/include cpp/rocksdb4pl.cpp /mingw64/lib/librocksdb.a -L/mingw64/lib/swipl/lib/x64-win64 -lswipl -lsnappy -lzstd -lz -llz4 -lbz2 -lshlwapi -lrpcrt4 -o lib/x64-win64/rocksdb4pl.dll

Groot@Galaxy MINGW64 /c/Users/Groot/AppData/Local/swi-prolog/pack/rocksdb
$ tree
.
├── Makefile
├── README.md
├── cpp
│   └── rocksdb4pl.cpp
├── demo
│   └── merge.pl
├── lib
│   └── x64-win64
│       └── rocksdb4pl.dll
├── pack.pl
├── prolog
│   └── rocksdb.pl
├── rocksdb
└── test
    └── test_rocksdb.pl

7 directories, 8 files
Groot@Galaxy MINGW64 /c/Users/Groot/AppData/Local/swi-prolog/pack/rocksdb
$ swipl
...

1 ?- use_module(library(rocksdb)).
true.

2 ?- rocks_open(".", R, []), rocks_put(R, app, noot), rocks_get(R, app, Noot), rocks_close(R).
R = <rocksdb>(0000026ad2bba590),
Noot = noot.