Description
I have two Maven packages: In project1
I use java-smt
with native solvers (specifically Z3). I then install project1
to my local Maven repository, and use it in project2
(where I set up the solver context etc.).
When I run project1
directly, I can successfully create the solver context by following the method outlined in the Example-Maven-Project, i.e. copying the org.sosy_lab.common
JAR and the native libraries to the same directory and setting the classpath there.
However, this fails when I create an uber-JAR (JAR with dependencies) using maven-shade-plugin
and try to run that, or when I try to run project2
. As far as I can tell, this happens because org.sosy_lab.common.NativeLibraries.loadLibrary()
tries to find the native libraries in the directory of the org.sosy_lab.common
JAR, or in java.library.path
, and project2
doesn't have the native libraries copied to a dependency
directory with the org.sosy_lab.common
JAR.
Is there a way to get native solvers working with either uber-JARs or dependent packages?
Alternatively, is there some way to load the libraries from a custom path? Usually when I depend on a native library, I package it as a resource, extract that to a temporary file and then load it using System.loadLibrary()
with the absolute path. I've tried doing that, but it seems that java-smt
tries to load the native libraries again anyways (and fails). I've also tried extracting the libraries to a temporary directory and adding that to java.library.path
, but adding library directories at runtime doesn't seem to work.