-
Notifications
You must be signed in to change notification settings - Fork 33
Troubleshooting
For JPL to be included in the compilation, CMAKE has to be able to find Java and JNI:
- Found JNI: /usr/lib/jvm/java-11-openjdk-amd64/lib/libjawt.so
-- JNI_INCLUDE_DIRS=/usr/lib/jvm/java-11-openjdk-amd64/include;/usr/lib/jvm/java-11-openjdk-amd64/include/linux;/usr/lib/jvm/java-11-openjdk-amd64/include
-- JNI_LIBRARIES=/usr/lib/jvm/java-11-openjdk-amd64/lib/libjawt.so;/usr/lib/jvm/java-11-openjdk-amd64/lib/server/libjvm.so
-- Found Java: /usr/bin/java (found version "11.0.7") found components: Development
While Java can be found if it is installed, finding JNI requires having JAVA_HOME
set:
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/
When loading JPL module in Prolog:
?- use_module(library(jpl)).
ERROR: /usr/lib/swi-prolog/library/jpl.pl:4243:
'$open_shared_object'/3: libjvm.so: cannot open shared object file: No such file or directory
ERROR: /usr/lib/swi-prolog/library/jpl.pl:4243:
/usr/lib/swi-prolog/library/jpl.pl:4243: Initialization goal raised exception:
library `java' does not exist (Please add directory holding libjava.so to $LD_LIBRARY_PATH)
ERROR: Exported procedure jpl:jpl_c_lib_version/1 is not defined
true.
Do a locate libjvm.so
to find where it is and add the path to LD_LIBRARY_PATH
so that library can be found:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/
or for OpenJDK
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/jvm/java-11-openjdk-amd64/lib/server/
System is unable to find the SWI Prolog framework, including failing to find library libswipl.so
.
Set-up:
-
SWI_HOME_DIR
: the location where SWI-Prolog is installed.- In Ubuntu distribution:
/usr/lib/swi-prolog/
- In local install for example:
/usr/local/swipl/lib/swipl/
- In Ubuntu distribution:
-
SWIPL_BOOT_FILE
: location of the.prc
booting file.- In Ubuntu distribution:
/usr/lib/swi-prolog/boot64.prc
- In local install for example:
/usr/local/swipl/lib/swipl/
- In Ubuntu distribution:
You need to tell the system to pre-load SWI main library:
export LD_PRELOAD=/home/ssardina/git/soft/prolog/swipl-devel.git/build/src/libswipl.so
Check this post and what is preloading?
Check this post.
This is resovled by loading libswipl.so
before by setting LD_PRELOAD
as above.
Some Prolog file is not able to find jpl.jar
that it needs to call some class. We need to setup CLASSPATH to point to JPL:
export CLASSPATH=</path/to/build>/packages/jpl/src/java/jpl.jar
That is the JAR file that CMAKE produces and the Prolog test code needs to be able to find it.