libswipl.dll is the dll you’re looking for.
A very simple hello world in c++ („member.cpp“)
#include "SWI-cpp.h"
#include <iostream>
int main(int argc, char** argv)
{
PlEngine e(argc, argv) ;
PlTermv args(2) ; // Prepare for member/2
args[0] = PlTerm(1.0) ; // first argument to member below
// args[1] is a variable
PlQuery q("member", args) ; // member(1, X)
q.next_solution() ; // now args[1] has [1 | _]
std::cout << (char*) args[1] << std::endl ;
q.next_solution() ; // now args[1] has [_, 1 | _]
std::cout << (char*) args[1] << std::endl ;
}
Compile with swipl-ld -o member member.cpp
As far as I understand, swipl-ld
adds a few compiler switches,
-fPIC -D_REENTRANT -D__SWI_PROLOG__ -D__SWI_EMBEDDED__ -mtune=generic
,
as well as a few linker flags,
-lswipl -Wl,-Bsymbolic-functions
.
All this applies for gcc
, unsure how it is in other systems.
Note that you can build SWI-Prolog yourself under MSYS2/gcc
, see here:
https://swi-prolog.discourse.group/t/compiling-with-msys2/3936/8
See also the manual:
https://www.swi-prolog.org/pldoc/man?section=cpp-embedding
https://www.swi-prolog.org/pldoc/man?section=plld