Skip to content

jschneeberger/jclingo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jclingo

This is a small example that creates a low-level binding java to clingo and calls the clingo_version() function and computes a stable model as an example.

The example requires clingo to be installed. If clingo has been installed in a non-standard location, -DClingo_DIR=<location> can be passed to help cmake find it. Similarly, the location of the java installation might have to be specified. For this, -DJAVA_HOME=<location> should be used.

Error Handling

The example implements no error handling whatsoever. This is of course important but also quite involved. Especially, when it comes to callbacks.

Example Setup on Ubuntu 20.04

Note that there are two cmake configure/build calls below. The first time the package is build will result in an error; the second call should run through. This is because swig generates a lot of java files, which would ideally be listed in CMakeLists.txt file. This can wait till the final version of the package because I expect this list of files to change a lot during development.

sudo add-apt-repository ppa:potassco/wip
sudo apt-get update
sudo apt install cmake swig openjdk-14-jdk g++ libclingo-dev
cmake -DJAVA_HOME=/usr/lib/jvm/java-14-openjdk-amd64 -B build
cmake --build build
cmake -B build
cmake --build build

If everything went right, the example can be executed like this:

➜ java -classpath build/jclingo_swig.jar:build/example.jar -Djava.library.path=build example
version: 5.5.0
ANSWER: a b

Hint for Development on Windows

Both clingo and swig should fully support Windows but setup on Windows might be more tricky. An easy alternative is to grab Ubuntu 20.04 from the Microsoft store and follow the above instructions.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published