bytedeco / javacpp

The missing bridge between Java and native C++
Other
4.48k stars 581 forks source link

User specifying Loader path and LinkerLibrary path? #667

Closed jbkyang-nvi closed 1 year ago

jbkyang-nvi commented 1 year ago

Context: We have a packaged *.jar file from javacpp-presets that we are trying to run in a container that has some access restrictions. Question:

  1. Can a user can specify the Loader's cached path (right now in `~/.javacpp/cache/) at runtime?
  2. Currently our built linkpath is specified in our build container (different from runtime container). Is there a way to change the linkpath that the bindings are looking for at runtime? Where is the generated linkpath specified? Would the recommended solution be to specify multiple possible linkpaths of where the library could be during creation of the *.jar?
saudet commented 1 year ago

Context: We have a packaged *.jar file from javacpp-presets that we are trying to run in a container that has some access restrictions. Question:

  1. Can a user can specify the Loader's cached path (right now in `~/.javacpp/cache/) at runtime?

Yes, users can set the "org.bytedeco.javacpp.cachedir" system property for that purpose: https://github.com/bytedeco/javacpp/wiki/System-Properties However, it automatically falls back on the tmp directory, so there's probably no need to worry about that.

  1. Currently our built linkpath is specified in our build container (different from runtime container). Is there a way to change the linkpath that the bindings are looking for at runtime? Where is the generated linkpath specified? Would the recommended solution be to specify multiple possible linkpaths of where the library could be during creation of the *.jar?

Users can always set the usual "java.library.path" system property for JNI: https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#getProperties-- At build time, it can also be done as part of the build system. For Maven, for example: https://github.com/bytedeco/javacpp-presets/blob/1.5.8/opencv/pom.xml#L93-L98

If there are only a few possible locations for the libraries, or defaults at least, we can hard code multiple paths in the @Platform annotation, sure, that's fine too.

saudet commented 1 year ago

Please let me know if this doesn't answer your questions though! Thanks

jbkyang-nvi commented 1 year ago

Hi @saudet sorry I was on vacation. Thanks for answering!