Run SWI-Prolog binary without swipl installed on the machine
Asked Answered
S

2

10

I want to run swi-prolog program on the machine (actually a server) where there is no prolog installed.

The prolog code swipl_test.pl:

 main :- write('Hello, world\n').

On the local machine 4.4.0-64-generic #85~14.04.1-Ubuntu SMP Mon Feb 20 12:10:54 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux making the binary hello with SWI-Prolog version 7.2.3 for amd64:

swipl  --goal=main --toplevel=halt --stand_alone=true  --foreign=save  -o hello1 -c swipl_test.pl

Moving hello on the remote machine 2.6.32-5-amd64 #1 SMP Wed Jun 17 16:09:06 UTC 2015 x86_64 GNU/Linux gives the following error:

error while loading shared libraries: libswipl.so.7.2: cannot open shared object file: No such file or directory 

How I can prepare a self-contained binary from a prolog code? I do not have sudo rights on the remote machine.

Segovia answered 8/3, 2017 at 15:9 Comment(0)
W
1

I had the same problem and i could solve it looking for the shared libraries necessary for the execution of my program. You can find these libraries by executing the ldd command. Once you have them, you can distribute them in the same directory as your executable and set the LD_LIBRARY_PATH variable so that the executable can find them.

This happens because, as clarified in the documentation, when using the option --stand_alone = true the executable becomes a copy of swipl with the saved state and, if SWI-Prolog is statically linked (by default in Linux/386) and the state does not use external packages, there will be no problems to run the program on another machine. Otherwise (our case) the shared objects must be made available so that the executable can find them. In Linux, these shared objects are found using ldd (in your case, the library libswipl.so.7.2). Therefore, you should look for this library (by default in /usr/lib) and copy it to the directory of your executable to distribute it with it. Then, in the machine where you are going to run the program, you must set the LD_LIBRARY_PATH variable so that the executable knows where to find those libraries that it needs to run, that is, the same directory where it is, or use chrpath(1) to change the address where the executable will search.

Wilhoit answered 26/7, 2018 at 23:40 Comment(0)
F
0

It is became available and possible to install swi prolog as:

pkg install swi-prolog

This will fix it

Fructification answered 12/12, 2020 at 17:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.