# Sweep-module.so undefined symbol: PL\_version\_info

**URL:** <https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842>\
**Category:** Installing\
**Tags:** bug\
**Created:** [October 11, 2022, 8:30am UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842 "2022-10-11T08:30:17Z")\
**Posts on this page:** 20\
**Page:** 1

<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:** [October 11, 2022, 8:30am UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/1 "2022-10-11T08:30:17Z")

</div>

Loading sweep-module entails this message error:

Loading /usr/local/lib/swipl/lib/x86\_64-linux/sweep-module.so (module)…  
Loading /usr/local/lib/swipl/lib/x86\_64-linux/sweep-module.so (module)…done  
emacs: symbol lookup error: /usr/local/lib/swipl/lib/x86\_64-linux/sweep-module.so: undefined symbol: PL\_version\_info  
Error: server did not start correctly

---

<div class="post-metadata">

**Author:** ![oskardrums](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/oskardrums/32/3594_2.png) [@oskardrums](https://swi-prolog.discourse.group/u/oskardrums)\
**Post date:** [October 11, 2022, 8:56am UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/2 "2022-10-11T08:56:58Z")

</div>

Hi Joseph,

Thanks for reporting, this looks like a known issue when using `sweep` on Linux that I’m working on alleviating. Currently the workaround is to start Emacs with `libswipl.so` preloaded, e.g. with:

```prolog
LD_PRELOAD=/path/to/libswipl.so emacs

```

Afterwards `sweep-module.so` should be able to locate `PL_version_info()` and the rest of the symbols defined in `libswipl.so`.  
Does this work for you?

---

<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:** [October 11, 2022, 9:18am UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/3 "2022-10-11T09:18:10Z")

</div>

Hi,

At the moment, unfortunately, this solutions fails:

Warning (initialization): An error occurred while loading ‘/home/joseph/.emacs.d/init.el’:

Symbol’s value as variable is void: LD\_PRELOAD=/usr/local/lib/swipl/lib/x86\_64-linux/libswipl.so

I’m using Prelude Emacs and I put this line of code in ~/.emacs.d/personal/preload

---

<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:** [October 11, 2022, 10:11am UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/4 "2022-10-11T10:11:46Z")

</div>

Emacs is a native executable. For LD\_PRELOAD to work the environment variable needs to be set **before** emacs is started, e.g., best as @oskardrums describes.

---

<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:** [October 11, 2022, 11:21am UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/5 "2022-10-11T11:21:51Z")

</div>

Thanks Jan. The trouble is that I do not understand what I have to do exactly.  
I have put in my .bashrc the following line:

```prolog
export PATH=$PATH:LD_PRELOAD=/usr/local/lib/swipl/lib/x86_64-linux/libswipl.so 

```

the result is the same. I am used to load emacs with emacs --daemon . I also test this in a terminal :

```prolog
joseph@mx:~$ LD_PRELOAD= /usr/local/lib/swipl/lib/x86_64-linux/sweep-module.so emacs
bash: /usr/local/lib/swipl/lib/x86_64-linux/sweep-module.so: Permission non accordée
joseph@mx:~$ sudo LD_PRELOAD= /usr/local/lib/swipl/lib/x86_64-linux/sweep-module.so emacs
[sudo] Mot de passe de joseph : 
sudo: /usr/local/lib/swipl/lib/x86_64-linux/sweep-module.so : commande introuvable

```

without success, as you can see. I am lost…

---

<div class="post-metadata">

**Author:** ![jamesnvc](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jamesnvc/32/14_2.png) [@jamesnvc](https://swi-prolog.discourse.group/u/jamesnvc)\
**Post date:** [October 11, 2022, 11:41am UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/6 "2022-10-11T11:41:07Z")

</div>

I don’t think specifying `LD_PRELOAD` in `PATH` will work. Your terminal test looks better, but there’s an extra space between the `=` and the path to the `.so`. Running `LD_PRELOAD=/usr/local/lib/swipl/lib/x86_64-linux/sweep-module.so emacs` should work.

---

<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:** [October 11, 2022, 11:45am UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/7 "2022-10-11T11:45:36Z")

</div>

Thanks for your attention, but even if that now emacs is started, finally it fails:

```prolog
LD_PRELOAD=/usr/local/lib/swipl/lib/x86_64-linux/sweep-module.so emacs

emacs: symbol lookup error: /usr/local/lib/swipl/lib/x86_64-linux/sweep-module.so: undefined symbol: PL_version_info

```

---

<div class="post-metadata">

**Author:** ![oskardrums](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/oskardrums/32/3594_2.png) [@oskardrums](https://swi-prolog.discourse.group/u/oskardrums)\
**Post date:** [October 11, 2022, 12:03pm UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/8 "2022-10-11T12:03:28Z")

</div>

you’re at the right direction, just preload libswipl instead of sweep-module 🙂

---

<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:** [October 11, 2022, 12:48pm UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/9 "2022-10-11T12:48:01Z")

</div>

I use a little script in ~/bin/emacs, holding the code below. Of course you may need to update the locations. This is IMO better as it only injects Prolog into Emacs, not in all programs you run. From Emacs-29 this should no longer be needed.

```prolog
#!/bin/sh
LD_PRELOAD=~/src/swipl-devel/build.pgo/src/libswipl.so /bin/emacs "$@"

```

---

<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:** [October 11, 2022, 6:27pm UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/10 "2022-10-11T18:27:01Z")

</div>

Oups !! Thanks for your attention !

---

<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:** [October 11, 2022, 6:27pm UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/11 "2022-10-11T18:27:55Z")

</div>

Many thanks Jan, thanks to all of you. It works now !

---

<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:** [October 12, 2022, 7:38pm UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/12 "2022-10-12T19:38:57Z")

</div>

> [@jan](#):
>
> From Emacs-29 this should no longer be needed.

I need the `LD_PRELOAD` with Emacs-29.0.50 on Debian 11 (bullseye) [ChromeBook]:

```shell
GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.16.0, Xaw3d scroll bars) of 2022-10-07

```

EDIT: I build SWI-prolog with `-DCMAKE_INSTALL_PREFIX=$HOME/.local`

---

<div class="post-metadata">

**Author:** ![oskardrums](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/oskardrums/32/3594_2.png) [@oskardrums](https://swi-prolog.discourse.group/u/oskardrums)\
**Post date:** [October 13, 2022, 5:02am UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/13 "2022-10-13T05:02:03Z")

</div>

> [@peter.ludemann](#):
>
> I need the `LD_PRELOAD` with Emacs-29.0.50

Yes, the plan is to solve this (for Emacs 29+) by having `sweeprolog.el` explicitly load `libswipl.so` before loading `sweep-module.so`. To do that we need to tweak `libswipl` a bit, see [Support loading libswipl as a GNU Emacs dynamic module by eshelyaron · Pull Request #1055 · SWI-Prolog/swipl-devel · GitHub](https://github.com/SWI-Prolog/swipl-devel/pull/1055) (I have a couple of comments from @jan to address wrt that PR, of course further comments are very welcome).  
Will update when that’s done.

---

<div class="post-metadata">

**Author:** ![oskardrums](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/oskardrums/32/3594_2.png) [@oskardrums](https://swi-prolog.discourse.group/u/oskardrums)\
**Post date:** [October 13, 2022, 9:18am UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/14 "2022-10-13T09:18:15Z")

</div>

> [@peter.ludemann](#):
>
> I need the `LD_PRELOAD` with Emacs-29.0.50

`LD_PRELOAD` should no longer be required with the latest SWI-Prolog (thanks @jan for merging the aforementioned PR) and the latest `sweep` (update with `M-x package-refresh-contents` followed by `M-x package-update sweep`)

Please do report if you still have problems running without `LD_PRELOAD` on Emacs 29

---

<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:** [October 13, 2022, 9:46am UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/15 "2022-10-13T09:46:38Z")

</div>

Looking better with each update 🙂 I’ve updated sweep for SWI-Prolog git tree as well. I think you can improve a little by having write\_sweep\_module\_location/0 in the sweep.pl module return all relevant info in one pass. For example emitting two lines if we need to preload libswipl as in

```
/path/to/libswipl.so
/path/to/sweep-module.so

```

In that case you can simply load add .so files from the result, where the last one is your module. You can of course also add some indication about the role of each .so file.

Notably on Windows the startup time of Prolog is relatively long.

---

<div class="post-metadata">

**Author:** ![oskardrums](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/oskardrums/32/3594_2.png) [@oskardrums](https://swi-prolog.discourse.group/u/oskardrums)\
**Post date:** [October 13, 2022, 9:51am UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/16 "2022-10-13T09:51:34Z")

</div>

Will do, the current implementation is admittedly a bit hacky in that area.

---

<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:** [October 13, 2022, 12:20pm UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/17 "2022-10-13T12:20:41Z")

</div>

I was happily surprised that on my Mac M1, starting Emacs, run

```
M-x pack-install RET sweeprolog RET

```

and all worked 🙂 This is a pretty much virgin Emacs installation from Macports.

P.s. That is with the SWI-Prolog built from source. It seems sweep is currently not installed properly in SWI-Prolog.app bundle ☹

---

<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:** [October 13, 2022, 4:36pm UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/18 "2022-10-13T16:36:22Z")

</div>

> [@oskardrums](#):
>
> `LD_PRELOAD` should no longer be required

`package-update` seemed to have problems, so I did a `package-delete`, `package-refresh-contents`, `package-install` for `sweeprolog` … got this message with `package-install`:

```bash
Compiling file /home/peter/.emacs.d/elpa/sweeprolog-0.6.1/sweeprolog-tests.el at Thu Oct 13 09:24:18 2022
Entering directory ‘/home/peter/.emacs.d/elpa/sweeprolog-0.6.1/’
sweeprolog-tests.el:3:2: Error: Failed to locate ‘sweep-module’. Make sure SWI-Prolog is installed and up to date
Compiling file /home/peter/.emacs.d/elpa/sweeprolog-0.6.1/sweeprolog.el at Thu Oct 13 09:27:31 2022
sweeprolog.el:1910:21: Warning: ‘flymake-show-diagnostics-buffer’ is an
    obsolete function (as of 1.2.1); use ‘flymake-show-buffer-diagnostics’
    instead.

```

I also got this message when I set `LD_PRELOAD` (which had worked with the earlier version of `sweeprolog`). As before, I’ve installed swipl in `~/.local/bin`, and it seems to run fine:

```bash
$ swipl 
Welcome to SWI-Prolog (threaded, 64 bits, version 8.5.18-39-g984787a12-DIRTY)
...
$ uname -a
Linux penguin 5.10.131-19114-g6651b07c6153 #1 SMP PREEMPT Thu Sep 1 19:07:41 PDT 2022 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye

```

Emacs is freshly rebuilt from source at git://git.sv.gnu.org/emacs.git 6efc64395282a960000d6fd9ac2e33ab7c764478:

```bash
GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.16.0, Xaw3d scroll bars) of 2022-10-13

```

(I’ll try this on Ubuntu 20.0.4 later today)

---

<div class="post-metadata">

**Author:** ![oskardrums](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/oskardrums/32/3594_2.png) [@oskardrums](https://swi-prolog.discourse.group/u/oskardrums)\
**Post date:** [October 13, 2022, 5:11pm UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/19 "2022-10-13T17:11:29Z")

</div>

Thank you for the detailed report.  
I suspect this indeed has to do with the fact that you have `swipl` installed in `~/.local/bin` because otherwise I can’t reproduce this on a pretty similar environment.  
I’ll see if I can reproduce it after installing `swipl` there. Would I be right to assume that you have `~/.local/bin` in your `PATH`?

EDIT: if you could also share the `cmake` flags you use to configure the `swipl` build that would be helpful.

---

<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:** [October 13, 2022, 5:24pm UTC](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842/20 "2022-10-13T17:24:27Z")

</div>

That’s the case, M-x sweeprolog-mode and my emacs crashes :

joseph@mx:~$ emacs --version  
GNU Emacs 29.0.50

emacs: symbol lookup error: /usr/local/lib/swipl/lib/x86\_64-linux/sweep-module.so: undefined symbol: PL\_version\_info

[Next page](https://swi-prolog.discourse.group/t/sweep-module-so-undefined-symbol-pl-version-info/5842.md?page=2)
