How to configure the location for the shared library so file in Bridj

101 views
Skip to first unread message

Daniel Korzekwa

unread,
Apr 21, 2017, 10:15:56 AM4/21/17
to NativeLibs4Java
Hello,

Using brid-0.7.0.jar. I managed to make bridj working for calling c from Scala only by setting @Library("mylibrary.so") and putting mylibrary.so file in the root scala project directory.

Is it possible to configure bridj to look for a native library under a classpath dir?, e.g. $project_dir/target or to configure the directory for native libs in some way?.

Also if I change Library("mylibrary.so") to Library("mylibrary") then bridj fails with:
INFO: Library not found : mylibrary
*** RUN ABORTED ***
  java.lang.UnsatisfiedLinkError: 



Marko Friedemann

unread,
May 19, 2017, 4:44:49 PM5/19/17
to NativeLibs4Java
Hey,


Daniel Korzekwa wrote:
Using brid-0.7.0.jar. I managed to make bridj working for calling c from Scala only by setting @Library("mylibrary.so") and putting mylibrary.so file in the root scala project directory.

Is it possible to configure bridj to look for a native library under a classpath dir?, e.g. $project_dir/target or to configure the directory for native libs in some way?.

Yes, you can call BridJ.addLibraryPath(path.getCanonicalPath) to set the path for the main library.
You can also call BridJ.getNativeLibrary(libName, libFile) to force BridJ to load other libraries that your lib depends on from specific files (otherwise it may extract them to a temprorary directory).

Do both before calling BridJ.register() and you get control over where it loads libraries from.

Also if I change Library("mylibrary.so") to Library("mylibrary") then bridj fails with:

I am not sure, I have just looked at code I have for this, and while I am using windows dlls, I don't actually have the .dll suffix for the main library (I do have it for the ones it depends on, though).

HTH,
M.
Reply all
Reply to author
Forward
0 new messages