Building prosqlite from source ? (with a view towards osquery)

Hi.

I’ve been trying to get to grips with SWI prolog. As I like to build things from source, I’ve been looking at how to build prosqlite from source.

Little build documentation.

I tried:

CFLAGS=-I/location/of/lib/swipl/include LDSOFLAGS=-lc PACKSODIR=$PWD/build make

Not very conclusive:

prosqlite.c:(.text+0x22): undefined reference to `PL_blob_data’

And lots of errors like that.

So. How do you people build stuff from source in the prolog world ?

Context: investigating how to integrate swipl and osquery, and as osquery is based on sqlite, I thought I’d have to start somewhere… I’d like low level integration.

prosqlite is organized as a “pack”. You build these from source using

 ?- pack_rebuild(prosqlite).

Or, in recent versions using

 swipl pack install --rebuild=true prosqlite

The pack has a Makefile that is called by Prolog, while passing several variables that describe the configuration of the target Prolog system. Rebuilding creates a file buildenv.sh in the pack that provides this environment.

In addition, there is swipl.cmake that provides CMake targets for embedding SWI-Prolog as well as generating plugins. The add-on
https://www.swi-prolog.org/pack/list?p=environ

is a recent example that configures a plugin using CMake.