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
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:
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?
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.
the result is the same. I am used to load emacs with emacs --daemon . I also test this in a terminal :
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
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.
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.
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
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.
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:
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:
$ 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:
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
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.