# Problems compiling Rocksdb

**URL:** <https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701>\
**Category:** Pack\
**Created:** [August 19, 2022, 6:02pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701 "2022-08-19T18:02:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pegesund](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@pegesund](https://swi-prolog.discourse.group/u/pegesund)\
**Post date:** [August 19, 2022, 6:02pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/1 "2022-08-19T18:02:57Z")

</div>

Hi, I am having trouble compiling the rocksdb-module on Linux.

I get pretty many of these errors: error: conversion from ‘PlTerm’ to ‘bool’ is ambiguous

Swipl version is 8.4.3 and gcc version is 12.1.1 - any clues?

Best,

Petter

---

<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:** [August 19, 2022, 6:13pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/2 "2022-08-19T18:13:55Z")

</div>

On 07/10/2022 was able to build [RocksDB pack](https://www.swi-prolog.org/pack/list?p=rocksdb) with [rocks-predicates](https://github.com/JanWielemaker/rocks-predicates) and recorded the exact commits.

See this [post](https://swi-prolog.discourse.group/t/persistent-predicates-based-on-rocksdb/5501/2) and click triangle to expand personal notes to see the commits.  
(Duplicated below)

```plaintext
07/10/2022
OS: Ubuntu 22.04 LTS
SWI-Prolog: Install via PPA development version 8.5.14
RocksDB pack commit: e253458
RocksDB commit: a9565ccb2
rocks-predicates commit: 3071007

```

So when you build it you will be pulling the exact commits possibly over writing the code you currently have.

---

<div class="post-metadata">

**Author:** ![pegesund](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@pegesund](https://swi-prolog.discourse.group/u/pegesund)\
**Post date:** [August 19, 2022, 6:27pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/3 "2022-08-19T18:27:30Z")

</div>

Hi, and thanks quick answer and sorry for being slow here 🙂

If I do a “git log” in the pack-directory the last commit is e253458069c7608e8d10a416c79c7e5ed5fac1d9

Should I checkout an earlier version?

---

<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:** [August 19, 2022, 6:34pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/4 "2022-08-19T18:34:16Z")

</div>

> [@pegesund](#):
>
> Should I checkout an earlier version?

If it were me I would start from those exact commits because I know they worked. If you read the many posts related to RocksDB pack a few weeks before 7/10/2022 you see that RockDB pack was not building and then after a few commits it would build with those commits loaded and using pack\_rebuild/0,1.

---

<div class="post-metadata">

**Author:** ![pegesund](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@pegesund](https://swi-prolog.discourse.group/u/pegesund)\
**Post date:** [August 19, 2022, 6:37pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/5 "2022-08-19T18:37:47Z")

</div>

Okay, will give it a try. Thx!

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [August 19, 2022, 6:41pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/6 "2022-08-19T18:41:13Z")

</div>

I use SWI-Prolog version 8.5.13 but with an older versions of gcc (9.4.0 on Ubuntu, 10.2.1 on Debian/Chromebook) … not sure if the older version of SWI-Prolog that you’re using (8.4.3) has the same version of `SWI-cpp.h`.

Note that a new version of `SWI-cpp.h` is under review and hopefully will go into the next release of SWI-Prolog; I have modified Rocksdb for the new version and have built/tested it (this update is also awaiting review).  
The new version of `SWI-cpp.h` is because of problems like the ambiguous conversions that has affected you.

I wonder why Ubuntu and Debian have such old versions of gcc, and what’s the best way to get newer versions? …

---

<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:** [August 19, 2022, 6:48pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/7 "2022-08-19T18:48:45Z")

</div>

> [@peter.ludemann](#):
>
> I wonder why Ubuntu and Debian have such old versions of gcc, and what’s the best way to get newer versions? …

This StackOverflow [answer](https://askubuntu.com/a/1370140/55600) seems plausible.

> Kernel updates may need to rebuild proprietary video modules from vendor supplied binary blobs, and this process is tested with the default compiler.

---

<div class="post-metadata">

**Author:** ![pegesund](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@pegesund](https://swi-prolog.discourse.group/u/pegesund)\
**Post date:** [August 19, 2022, 6:50pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/8 "2022-08-19T18:50:18Z")

</div>

Yes, still having same problem - even on the versions you did mention. But I am however on 8.4.3 still, so this is probably the problem.

Ps, I had to add the flag: -Wno-error on this verison of gcc to get to this point.

I can probably wait for the new version and then hopefully it will be fixed with the new version of the header-file.

Yes, that is really an old gcc, but guess many are moving towards clang these days.

---

<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:** [August 19, 2022, 6:56pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/9 "2022-08-19T18:56:10Z")

</div>

> [@pegesund](#):
>
> still having same problem

I would try and recreate your problem but having a working version of RocksDB with rocks-predicates for SWI-Prolog was so hard to get I don’t want to ruin it and then be without. 🙁

FYI - When I did the build it was on Ubuntu on WSL 2 on Windows 10. That should not make a difference but I have seen odder.

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [August 19, 2022, 7:01pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/10 "2022-08-19T19:01:50Z")

</div>

> [@pegesund](#):
>
> I am however on 8.4.3 still, so this is probably the problem.

I’ve installed gcc version 11 (using the instructions at [Reddit - Dive into anything](https://www.reddit.com/r/Ubuntu/comments/ptixle/is_there_a_ppa_that_always_has_the_latest_gcc/)) … I’ll try to rebuild using both the older version of `SWI-cpp.h` and the new version and see how that goes. But it might be a few days before I can do this (I have everything currently set up to use the new version of `SWI-cpp.h`).  
gcc version 12 seems to be “bleeding edge” – it doesn’t show in the PPA that I added (ppa:ubuntu-toolchain-r/test) – so you might want to try version 11.

---

<div class="post-metadata">

**Author:** ![pegesund](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@pegesund](https://swi-prolog.discourse.group/u/pegesund)\
**Post date:** [August 19, 2022, 7:19pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/11 "2022-08-19T19:19:05Z")

</div>

Great, I am on Manjaro Linux, so guess I will just follow the dist version to make life simple 🙂

If we are moving towards the new header-file I am fully happy waiting for this also!

---

<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:** [August 19, 2022, 7:21pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/12 "2022-08-19T19:21:36Z")

</div>

Here is the topic with my recent endeavor to get the RocksDB pack for SWI-Prolog building.

[Pack RocksDB, build fails on Ubuntu 22.04 LTS on WSL on Windows (reproducible)](https://swi-prolog.discourse.group/t/pack-rocksdb-build-fails-on-ubuntu-22-04-lts-on-wsl-on-windows-reproducible/5559)

---

<div class="post-metadata">

**Author:** ![pegesund](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@pegesund](https://swi-prolog.discourse.group/u/pegesund)\
**Post date:** [August 19, 2022, 7:37pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/13 "2022-08-19T19:37:48Z")

</div>

Thanks for info, but still having the same issue 🙂

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [August 19, 2022, 7:44pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/14 "2022-08-19T19:44:32Z")

</div>

> [@pegesund](#):
>
> If we are moving towards the new header-file I am fully happy waiting for this also!

The new header file can be used right now, although you’d have to replace it in `lib/swipl/include` (or modify the “`-I`” parameter to g++). If you want to wait until it’s in the “development” version of SWI-Prolog, that’s up to @jan . I doubt that it’d be back-ported to the “stable” version.

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [August 19, 2022, 8:29pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/15 "2022-08-19T20:29:21Z")

</div>

I tried compiling the “development” version with gcc version 11, and didn’t get any errors. So, I suspect your problem is with the “stable” version of `SWI-cpp.h`. You could try replacing just the current (8.5.15) “development” version of `SWI-cpp.h` and see what happens – it’s independent of everything else and merely calls functions that are defined in `SWI-Prolog.h`, so it should work with the “stable” API.

---

<div class="post-metadata">

**Author:** ![pegesund](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@pegesund](https://swi-prolog.discourse.group/u/pegesund)\
**Post date:** [August 20, 2022, 11:19am UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/16 "2022-08-20T11:19:02Z")

</div>

Hi, checked out the 5-version of swi prolog and changed the -I include parameter to point to the new header files.

But still same problem - which is strange as I now have pretty much same setup as you. Now the only diff should be the version of the gcc, maybe.

* * *

commit c723033a96b1e6649e2b2f0c481adaf1db1e7539 (tag: V8.5.15)  
Author: Jan Wielemaker [J.Wielemaker@vu.nl](mailto:J.Wielemaker@vu.nl)  
Date: Thu Jul 28 14:06:16 2022 +0200

```
Preparing version 8.5.15

```

---

<div class="post-metadata">

**Author:** ![pegesund](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@pegesund](https://swi-prolog.discourse.group/u/pegesund)\
**Post date:** [August 20, 2022, 12:33pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/17 "2022-08-20T12:33:45Z")

</div>

Hi, happy to say it works fine now. I did copy the latest version of SWI-cpp.h from the packages-cpp repo and it solved it, after tuning the gcc-flags a little.

Thanks for really nice help!

Petter

---

<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:** [August 20, 2022, 12:55pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/18 "2022-08-20T12:55:32Z")

</div>

> [@pegesund](#):
>
> Hi, happy to say it works fine now.

Care to share the details.

---

<div class="post-metadata">

**Author:** ![pegesund](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@pegesund](https://swi-prolog.discourse.group/u/pegesund)\
**Post date:** [August 20, 2022, 1:36pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/19 "2022-08-20T13:36:42Z")

</div>

Sure. I checked out latest version of swi and the same with packages-cpp.

Then I updated the include flags in the buildenv.sh to point to the new header locations. Also added -Wnoerror in the cflags to be able to compile rocks itself.

Then I did a make and after this I was able to load the library and run some tests from swi. Looking forward to have rocksdb write speed from prolog 🙂

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [August 20, 2022, 3:29pm UTC](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701/20 "2022-08-20T15:29:41Z")

</div>

> [@pegesund](#):
>
> after tuning the gcc-flags a little

Please give me the gcc flags information so that I can update the build options. And if you have the error messages from rebuilding, please email them to me. (You might want to open a bug report with rocksdb – it seems to be under active development)

I didn’t need to do anything to get things to compile with gcc version 11 [\*], so I suspect your problems have to do with enhancements with gcc version 12. I had come across problems with implicit conversions to `bool` while I was modifying `SWI-cpp.h` (and some even weirder ones with `double`), so it wouldn’t surprise me if there are some latent problems there. The new version of `SWI-cpp.h` takes a more conservative approach to implicit conversions, but is a bit more verbose because of that.

One other question: which language standard of C++ are you using? I needed to set the flag `-std=c++17` to get rocksdb to build (this is in the Makefile for the pack) and it’s possible that a newer language standard might cause other problems. (I think that SWI-Prolog uses `-std=c++11` by default.)

[\*] I haven’t rebuilt the rocksdb library recently, so there might be some things there that don’t work with gcc version 11. I’ll try to check that out soon, because installing the rocksdb pack rebuilds the library.

[Next page](https://swi-prolog.discourse.group/t/problems-compiling-rocksdb/5701.md?page=2)
