It’s possible, but a little on the difficult side.
Have you used JNI before? Will you be the one making the call to System.load() or System.loadLibrary() or are you using a 3rd-party library/jar that does that on its own?
At the moment I found that solution:
a. in the driver I loaded the library: static {System.loadLibrary(“myLib”);}
b. then i copied the myLib.dll in the Ignition lib directory.
The solution works, but it’s not “elegant”
Have you some suggestion or better solution?
May I ask you another thing not inherent native lib in this post? Or I have to open a new one?
One solution is to do what you do; place the native library in Ignition’s lib folder (which gets added to java.library.path during startup via reflection voodoo) and then use System.loadLibrary().
The other more “portable” solution is to package the native library inside one of your jar files and during module startup copy the native library to a temporary directory and use System.load() on it.
I’m using loadLibrary as well and I get this:
com.inductiveautomation.ignition.common.modules.ModuleLoadException: Unable to load hook class “company.com.focas_ignition.GatewayHook” for module “company.com.focas-ignition”
…
…
Caused by: java.lang.UnsatisfiedLinkError: C:\Program Files\Inductive Automation\Ignition\lib\FwlibWrapper.dll: Can’t find dependent libraries
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(Unknown Source)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(Unknown Source)
at java.base/java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.base/java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.base/java.lang.Runtime.loadLibrary0(Unknown Source)
at java.base/java.lang.System.loadLibrary(Unknown Source)
at company.com.focas_ignition.FocasWrapper.(FocasWrapper.java:12)
at company.com.focas_ignition.GatewayHook.(GatewayHook.java:29)
There is a few DLLs that FwlibWrapper.dll link to. I’ve tried putting them in C:\Program Files\Inductive Automation\Ignition\lib along with FwlibWrapper.dll. I realize this is probably a jetty issue with its class loader. I also tried adding the dependent DLLs in a library on the PATH.