aborsu / scala-unitex

Example of using the UnitexJni from scala
GNU General Public License v3.0
0 stars 0 forks source link

Unsatisfied link error on OS X #1

Open nrinaudo opened 8 years ago

nrinaudo commented 8 years ago

After following the (clear!) instructions on OS X, I get to the point where I can execute the project with its default arguments. This fails almost immediately with an UnsatisfiedLinkError:

[info] Running UnitexJniDemo 
is ms-windows:false : Mac OS X /
Usage : UnitexJniDemo [ressource_dir] [base_work_dir] [nb_loop] [param]
  param=0 : no vfs and no persistance
  param=1 : vfs and no persistance
  param=2 : no vfs and persistance
  param=3 : vfs and persistance (fastest)

resource path : './demojnires' and work path is './demojnires' and 8 executions
[error] (run-main-3) java.lang.UnsatisfiedLinkError: fr.umlv.unitex.jni.UnitexJni.unitexAbstractPathExists(Ljava/lang/String;)Z
java.lang.UnsatisfiedLinkError: fr.umlv.unitex.jni.UnitexJni.unitexAbstractPathExists(Ljava/lang/String;)Z
at fr.umlv.unitex.jni.UnitexJni.unitexAbstractPathExists(Native Method)
at UnitexJniDemo$.getVirtualFilePfx(Main.scala:45)
at UnitexJniDemo$.main(Main.scala:124)
at UnitexJniDemo.main(Main.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at scala.sys.package$.error(package.scala:27)

I'm at a bit of a loss there, since some Unitex code is obviously executed, if only Jni.isUnderWindows()...

nrinaudo commented 8 years ago

Well, don't I feel stupid now. If I modify the code to load the dynamic library explicitly, it works:

java.lang.Runtime.getRuntime().load("./lib/libUnitexJni.dylib")

It might be interesting to modify the code to load the appropriate library at boot-time, as JNI is often seen as black magic and hugely confusing to developers. I'd be happy to submit a PR if you feel it's worth it.