9 releases

0.3.6 Feb 20, 2024
0.3.5 Aug 3, 2023
0.3.4 Aug 13, 2022
0.3.3 Jan 24, 2022
0.1.0 Apr 28, 2021

#39 in #foreign-interface

Download history 32/week @ 2024-07-21 76/week @ 2024-07-28 23/week @ 2024-08-04 16/week @ 2024-08-11 17/week @ 2024-08-18 19/week @ 2024-08-25 17/week @ 2024-09-01 18/week @ 2024-09-08 9/week @ 2024-09-15 30/week @ 2024-09-22 24/week @ 2024-09-29 11/week @ 2024-10-06 15/week @ 2024-10-13 22/week @ 2024-10-20 26/week @ 2024-10-27 32/week @ 2024-11-03

96 downloads per month
Used in swipl

Apache-2.0/MIT

8KB
73 lines

swipl-fli - low-level bindings for SWI-Prolog's foreign language interface

This crate provides low-level bindings for SWI-Prolog's foreign language interface. The bindings are generated using bindgen. SWI-Prolog's header files and shared library are discovered by using the swipl binary found either on PATH or in the SWIPL environment variable.

Documentation

Runtime library discovery

Unless SWI-Prolog's dynamic library is automatically discoverable by your operating system, running anything that depends on this crate, including unit tests, will fail with an error saying that the shared library cannot be found. Unfortunately, it does not seem to be possible to embed the library's location at compile time in a portable way.

In order to make things run, you'll have to add the shared library's directory to the library load path. On linux, this can be done by setting the environment LD_LIBRARY_PATH. For example,

LD_LIBRARY_PATH=/home/matthijs/.swivm/lib/x86_64-linux/:$LD_LIBRARY_PATH cargo test

This is pretty cumbersome. To help out, consider installing cargo-swipl. With cargo-swipl, the above turns into this:

cargo swipl test

For a more permanent solution, consider using a tool like chrpath to embed the library's location in your binary. Alternatively, you can let SWI-Prolog handle the building of standalone binaries, by loading your native library in a swipl process and performing a qsave.

Dependencies

~0–1.9MB
~37K SLoC