Codebase list swi-prolog / 109af2a1-1aa9-45ee-9e2f-3bf3c7edfa79/main packages / cpp
109af2a1-1aa9-45ee-9e2f-3bf3c7edfa79/main

Tree @109af2a1-1aa9-45ee-9e2f-3bf3c7edfa79/main (Download .tar.gz)

# SWI-Prolog C++ interface

## Embedding SWI-Prolog in a C++ program

The files likes.pl and  likes.cpp  provide   a  simple  example emedding
SWI-Prolog. To compile, run

    swipl-ld -o likes likes.cpp likes.pl

Next, run as e.g.

    ./likes john
    ./likes -happy

## Extending SWI-Prolog using C++ code

The files `test.pl` and `test.cpp` add foreign predicates to SWI-Prolog.
To compile, run

    swipl-ld -o test -shared test.cpp

Next, run as e.g.

    swipl test.pl
    ?- hello(world).
    Hello world
    true.

History of packages / cpp @109af2a1-1aa9-45ee-9e2f-3bf3c7edfa79/main