Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Maven and OS X UnsatisfiedLinkError org.bytedeco.javacpp.opencv_core #49

Closed
hfjn opened this issue Nov 6, 2014 · 13 comments
Closed

Comments

@hfjn
Copy link

hfjn commented Nov 6, 2014

Hi. I'm trying to use JavaCV for an easy Jetty Server. It builds just fine, but when initializing the Class that uses JavaCV the first time the whole thing crashes with:

java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1764) at java.lang.Runtime.loadLibrary0(Runtime.java:823) at java.lang.System.loadLibrary(System.java:1044) at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535) at org.bytedeco.javacpp.Loader.load(Loader.java:410) at org.bytedeco.javacpp.Loader.load(Loader.java:353) at org.bytedeco.javacpp.opencv_core.<clinit>(opencv_core.java:10) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:249) at org.bytedeco.javacpp.Loader.load(Loader.java:385) at org.bytedeco.javacpp.Loader.load(Loader.java:353) at org.bytedeco.javacpp.opencv_core$Algorithm.<clinit>(opencv_core.java:8797) at uos.jhoffjann.server.logic.OCV.<init>(OCV.java:22)

I got the JavaCV libraries as described here. Am I just missing the platform.dependeciespart? I wasn't able to find a Maven property which is called like that, so I couldn't activate it.

This is the relevant part in my pom.xml:

<dependency>
        <groupId>org.bytedeco</groupId>
        <artifactId>javacpp</artifactId>
        <version>0.9</version>
    </dependency>
     <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>opencv</artifactId>
        <version>2.4.9-0.9</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>ffmpeg</artifactId>
        <version>2.3-0.9</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>flycapture</artifactId>
        <version>2.6.3.4-0.9</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>libdc1394</artifactId>
        <version>2.2.2-0.9</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>libfreenect</artifactId>
        <version>0.5-0.9</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>videoinput</artifactId>
        <version>0.200-0.9</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>artoolkitplus</artifactId>
        <version>2.3.0-0.9</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>flandmark</artifactId>
        <version>1.07-0.9</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>fftw</artifactId>
        <version>3.3.4-0.9</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>gsl</artifactId>
        <version>1.16-0.9</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>llvm</artifactId>
        <version>3.4.2-0.9</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>leptonica</artifactId>
        <version>1.71-0.9</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>tesseract</artifactId>
        <version>3.03-rc1-0.9</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco</groupId>
        <artifactId>javacv</artifactId>
        <version>0.9</version>
    </dependency>

`
I would be extremely glad for any help.

@saudet
Copy link
Member

saudet commented Nov 7, 2014

Does it work if you set the platform.dependencies system property as shown on the page below?
https://github.com/bytedeco/javacpp-presets/tree/master/opencv#sample-usage

@hfjn
Copy link
Author

hfjn commented Nov 7, 2014

Thanks for your answer. Unfortunately I get the same error. I started my application with:
mvn jetty:run -Dplatform.dependencies
It downloaded a ton of new jars but when I access the function which should use JavaCV it still crashes with:
java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path
Further down the stack trace I can also find this possible interesting part:
aused by: java.lang.UnsatisfiedLinkError: /private/var/folders/m2/4b8pqw2j5lndmnjrqf7ncnbc0000gn/T/javacpp1415322937425337000/libjniopencv_core.dylib: Library not loaded: @rpath/libopencv_core.2.4.dylib Referenced from: /private/var/folders/m2/4b8pqw2j5lndmnjrqf7ncnbc0000gn/T/javacpp1415322937425337000/libjniopencv_core.dylib Reason: no suitable image found. Did find: /private/var/folders/m2/4b8pqw2j5lndmnjrqf7ncnbc0000gn/T/javacpp1415322937425337000/./libopencv_core.2.4.dylib: malformed mach-o image: load command #12 length (0) too small in /private/var/folders/m2/4b8pqw2j5lndmnjrqf7ncnbc0000gn/T/javacpp1415322937425337000/./libopencv_core.2.4.dylib

@saudet
Copy link
Member

saudet commented Nov 7, 2014

I see, we've got a duplicate issue for that here: bytedeco/javacpp#6

@hfjn
Copy link
Author

hfjn commented Nov 7, 2014

Oh. That sounds indeed oddly familiar. Is there an easy way to use those new binaries with maven? Or do I need to create a local repository for them? Thanks for helping!

@saudet
Copy link
Member

saudet commented Nov 7, 2014

It's a normal snapshot repository, so we can add it to the pom.xml file, but I haven't taken the time to make sure all the pom.xml files are cooperating well here, so it might be easier to build what you need locally yes.

@hfjn
Copy link
Author

hfjn commented Nov 7, 2014

Okay. I tried to use the binaries you posted here and maybe I'm just not that intelligent today, but the only useable .jar I could find was ffmpeg-2.4.2-0.9.1-20141101.094631-4-macosx-x86_64.jar. I would be extremely thankful if you could elaborate what I need to do with the javacpp-folder you posted. I just switched from OpenCV for Java to your library and I have the feeling that I missed something essential when setting everything up.

Let me explain what I did. Maybe it's obvious what I forgot to do. (Code for context):

  1. Added the dependencies (now with the ffmpeg.jar from the local repo):

    <dependency>
        <groupId>org.bytedeco</groupId>
        <artifactId>javacpp</artifactId>
        <version>0.9</version>
    </dependency>
    
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>opencv</artifactId>
        <version>2.4.9-0.9</version>
    </dependency>
    
    <dependency>
        <groupId>org.bytedeco.javacpp-presets</groupId>
        <artifactId>ffmpeg</artifactId>
        <version>2.4.2-0.9.1-SNAPSHOT</version>
    </dependency>
    
    <dependency>
        <groupId>org.bytedeco</groupId>
        <artifactId>javacv</artifactId>
        <version>0.9</version>
    </dependency>
    
  2. added this plugin.
    <plugin> <groupId>org.bytedeco</groupId> <artifactId>javacpp</artifactId> <version>0.9</version> </plugin>

  3. $ mvn clean install

  4. $ mvn jetty:run -Dplatform.dependencies

Thanks in advance!

@saudet
Copy link
Member

saudet commented Nov 7, 2014

Like I said, it's probably easier to just run cppbuild.sh install and mvn install to build everything locally from source. I didn't test anything of the snapshots, and it's really hard to get those right.

@hfjn
Copy link
Author

hfjn commented Nov 7, 2014

Many thanks. I redid everything and built the whole javacpp-presets as you told me and it just worked. Now I can concentrate on fixing the real problems. Thank you again!

@hfjn hfjn closed this as completed Nov 7, 2014
@gaurav-chawla
Copy link

Add opencv-os.jar in your class path.
For Mac:
Copy opencv-macosx-x86_64.jar inside /System/Library/Java/Extensions/

@SaleemKhair
Copy link

@jhoffjann can you please provide what exactly you did,
I am facing the same issue
thanks.

@hfjn
Copy link
Author

hfjn commented May 16, 2016

@SaleemKhair I ran into other problems later in the project. I eventually switched to OpenCV and got my project running with that. Back then I did it like that: http://aufeinwort.org/2014/10/get-opencv-up-and-running-with-intellij-and-mac-os-x/

@namannigam-zz
Copy link

@hfjn The last link seems to be broken. We want to switch to using openCv as well, jsut curious to see what changes did you bring.

@hfjn
Copy link
Author

hfjn commented Mar 3, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants