I have had difficulties using CRAFTY Brazil on Linux Mint 20 (based on Ubuntu 20.04). Despite having Open MPI version 4.0.3 installed (installed with apt install openmpi
). When attempting to run CRAFTY Brazil v1.0.1 I receive the following error.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no savesignals in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
at java.lang.Runtime.loadLibrary0(Runtime.java:871)
at java.lang.System.loadLibrary(System.java:1124)
at mpi.MPI.<clinit>(MPI.java:59)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.volante.abm.serialization.ModelRunner.main(ModelRunner.java:72)
To confirm the issue is specifically related to the use of MPI I commented out all references to MPI in ModelRunner.java
and WorldLoader.java
, and successfully ran the model. To further isolate the problem I wrote the following short test program and saved it as src/DemoMpiUnsatisfiedLinkError.java
within the CRAFTY Brazil project.
import mpi.MPI;
import mpi.MPIException;
public class DemoMpiUnsatisfiedLinkError {
public static void main(String[] args) throws MPIException {
System.out.println("Started MPI test");
String libPath = System.getProperty("java.library.path");
System.out.println(libPath);
String[] mpiArgs = MPI.Init(args);
}
}
This is compiled and run using only the lib/mpi.jar
file on the classpath with
CRAFTY_HOME=/home/andrew/Documents/codes/crafty-brazil/CRAFTY_Brazil
# Compile test program
javac -classpath $CRAFTY_HOME/lib/mpi.jar \
-d $CRAFTY_HOME/bin \
$CRAFTY_HOME/src/DemoMpiUnsatisfiedLinkError.java
# Run test program
/usr/lib/jvm/bellsoft-java8-full-amd64/bin/java \
-classpath $CRAFTY_HOME/lib/mpi.jar:$CRAFTY_HOME/bin \
DemoMpiUnsatisfiedLinkError
Producing the output
Started MPI test
/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Exception in thread "main" java.lang.UnsatisfiedLinkError: no savesignals in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
at java.lang.Runtime.loadLibrary0(Runtime.java:871)
at java.lang.System.loadLibrary(System.java:1124)
at mpi.MPI.<clinit>(MPI.java:59)
at DemoMpiUnsatisfiedLinkError.main(DemoMpiUnsatisfiedLinkError.java:10)
I can see mpi.jar
was copied into the lib
directory of the CRAFTY CoBRA repository in this commit but can't find further documentation about where the code archive came from. Some web searching indicates the mpi.jar
archive that is distributed with CRAFTY CoBRA is likely derived from the mpiJava package. In particular, src/Java/mpi/MPI.java
within mpiJava refers to a library called savesignals
. However I haven't been able to find the libsavesignals.so
file that is referenced in the Makefiles within the mpiJava package source. I also haven't been able to successfully compile the package whose steps, I suppose, might generate libsavesignals.so
.
Both ModelRunner.java
and WorldLoader.java
were modified by the CRAFTY CoBRA developert in 2020 to handle UnsatisfiedLinkErrors
such as the one I have found (see commits 640136b and c8adffc). However the changes are mixed in with other changes that I fear will break CRAFTY Brazil.
Notes from efforts to compile mpiJava
It was necessary to link the file jni_md.h to the include directory of the java installation
/usr/lib/jvm/bellsoft-java8-full-amd64/include/linux/jni_md.h
ln -s /usr/lib/jvm/bellsoft-java8-full-amd64/include/linux/jni_md.h /usr/lib/jvm/bellsoft-java8-full-amd64/include/jni_md.h