UnsatisfiedLinkError using clojure.lang.RT/loadLibrary

337 views
Skip to first unread message

Antonio Recio

unread,
Dec 17, 2011, 2:30:30 PM12/17/11
to clo...@googlegroups.com
When I try to load native libraries in the System ClassLoader I get an error of cannot open shared object file, and I don't know how to solve it.

In linux in REPL :
clojure java -Djava.library.path=/usr/local/lib/vtk-5.9/ -cp /usr/share/java/clojure.jar:/usr/local/lib/vtk-5.9/java/vtk.jar clojure.main

when I execute this code :
(ns project.core
  (:import (javax.swing JButton JFrame JPanel)
           (vtk vtkConeSource vtkPolyDataMapper vtkRenderWindow
                vtkRenderWindowInteractor vtkCamera vtkActor vtkRenderer
                vtkInteractorStyleTrackballCamera)))

(clojure.lang.RT/loadLibrary "vtkCommonJava")

I obtain this error :
UnsatisfiedLinkError /usr/local/lib/vtk-5.9/libvtkCommonJava.so.5.9.0: libvtkCommon.so.5.9: cannot open shared object file: No such file or directory  java.lang.ClassLoader$NativeLibrary.load (ClassLoader.java:-2)

Baishampayan Ghose

unread,
Dec 18, 2011, 11:20:46 AM12/18/11
to clo...@googlegroups.com
It seems the JVM is unable to locate certain shared library in the
path you specified. Can you see whether that .so file actually exists
in that directory?

This is what the VTK wiki says about this type of errors -
http://www.vtk.org/Wiki/VTK/FAQ#When_I_try_to_run_my_program_with_Java-wrapped_VTK.2C_why_do_I_get_.22java.lang.UnsatisfiedLinkError:_no_vtkSomeLibraryName.22.3F

Regards,
BG

> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

--
Baishampayan Ghose
b.ghose at gmail.com

Dave Ray

unread,
Dec 18, 2011, 12:27:52 PM12/18/11
to clo...@googlegroups.com
java.library.path is only good for the first "layer" of libraries you
load. Any dependent libs (like libvtkCommon.so) are loaded with the
normal dynamic loading provided by the OS. So, i think there's two
options:

* Just use LD_LIBRARY_PATH env variable (or OS equivalent) and don't
bother with java.library.path.
* Make sure all the libs are loaded manually in the right order:

(clojure.lang.RT/loadLibrary "vtkCommon")
(clojure.lang.RT/loadLibrary "vtkCommonJava")

Now the "vtkCommon" lib is already loaded before "vtkCommonJava". Of
course, this means you have to figure out the deps, sort them, and
deal with changes over time. Good times.

Hope this helps,

Dave

Reply all
Reply to author
Forward
0 new messages