Moving OpenCV to another folder breaks it

asked 2016-07-27 09:54:58 -0600

Stefan Reich gravatar image

Here is a weird thing. I am calling OpenCV 2.4.9 from Java (on Peppermint Linux 3).

It works fine.

But, when I rename the OpenCV installation directory (and of course the reference to the directory in my Java source) - it breaks.

Here's the error message:

java.lang.UnsatisfiedLinkError: /home/stefan/dev/opencv-2.4.9_/lib/libopencv_java249.so: libopencv_features2d.so.2.4: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)

So it DID find the first library (libopencv_java249.so) - but not the second one (libopencv_features2d.so.2.4). Even though both are in the same folder.

Does OpenCV remember the folder it is installed in? Is this about an env variable? (Not aware of any variables set.)

Sources: http://tinybrain.de/1003793 (original dir) http://tinybrain.de/1003796 (moved dir)

edit retag flag offensive close merge delete

Comments

1
  • you should have built the opencv libs statically, so opencv_java.so no more depends on other opencv so's

  • if you rename the folder, where the opencv so's are located, you'll have to re-run ldconfig there

berak gravatar imageberak ( 2016-07-27 09:59:21 -0600 )edit

Thanks. Are there not statically built libraries available online? I am looking into redistributing OpenCV for end users as easily as possible (still an unsolved problem). The software I make is supposed to require nothing but Java and download anything needed from the web.

Stefan Reich gravatar imageStefan Reich ( 2016-07-27 10:21:33 -0600 )edit

"Are there not statically built libraries available online?"

not so.

" The software I make is supposed to require nothing but Java and download anything needed from the web."

nice idea, but it won't work. again, opencv is mainly a c++ library (with python & java wrappers). you probably won't be able to prebuild the native binaries for all available os'es, so making a script that downloads opencv src andbuilds it locally is your only option here. (and java might not be the most easy choice, sad as it is..)

berak gravatar imageberak ( 2016-07-27 10:29:38 -0600 )edit

Aren't there binary OpenCV distributions on sourceforge, or am I making this up? And isn't there a way to build Linux libraries portably?

Actually Java 8 itself is distributed this way (just untar it on any Linux and it works!) - and it's full of native libraries...

I'm still hoping for a solution here :-) A simple zip file with all the OpenCVs .so's built properly and portably?

Stefan Reich gravatar imageStefan Reich ( 2016-07-27 10:41:35 -0600 )edit

"Aren't there binary OpenCV distributions on sourceforge,"

that's true. but they're for win only, and idk if they conttain java wrappers as well.

berak gravatar imageberak ( 2016-07-27 11:21:39 -0600 )edit

"A simple zip file with all the OpenCVs .so's built properly and portably?"

again that would be like 17 "simple" zips, one for win32 , one for win64, one for ...

berak gravatar imageberak ( 2016-07-27 11:53:12 -0600 )edit