编程语言
首页 > 编程语言> > java-sikuli classpath UnsatisfiedLinkError否opencv_core与macosx intellij Junit

java-sikuli classpath UnsatisfiedLinkError否opencv_core与macosx intellij Junit

作者:互联网

我已经进行了先前的搜索,试图找到答案,但是到目前为止,我的尝试失败了.我认为错误很简单,就是不加载类.

我正在使用intellij运行MacOSX 10.我在Junit Spring和Maven&中使用它朱尼特

我遵循了发现的Maven依赖项mvnrepository.com – sikuli-api 1.2.0,所以我在想,如果将依赖项添加到pom,那么所有文件都应该在我的类路径中?所以我不明白为什么它不起作用?

这个previous answer看起来很接近我的-但它适用于Mac上的Windows im.但是,通过使用Maven,我不需要将其添加到类路径中?还是我错过了一些东西.这个similar unanswered问题看起来也像Mac一样

添加了POM依赖关系

    <dependency>
        <groupId>org.sikuli</groupId>
        <artifactId>sikuli-api</artifactId>
        <version>1.2.0</version>
    </dependency>

    <dependency>
        <groupId>org.sikuli</groupId>
        <artifactId>sikuli-core</artifactId>
        <version>1.2.2</version>
    </dependency>

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>14.0.1</version>
    </dependency>
    <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>
        <classifier>macosx-x86_64</classifier>
    </dependency>
    <dependency>
        <groupId>org.piccolo2d</groupId>
        <artifactId>piccolo2d-core</artifactId>
        <version>1.3.1</version>
    </dependency>
    <dependency>
        <groupId>org.piccolo2d</groupId>
        <artifactId>piccolo2d-extras</artifactId>
        <version>1.3.1</version>
    </dependency>

我的测试

static {
    System.setProperty("platform.dependency", "macosx-x86_64");
    //System.setProperty("platform.dependency", "1");  // tried this also
}

@Test
public void testOne() throws Exception {

    File file = new File(getClass().getClassLoader().getResource("camera_icon.png").getFile());

    browse(new URL("http://code.google.com"));

    ScreenRegion s = new DesktopScreenRegion();
    Target target = new ColorImageTarget(file);

    // ** Fails here  **
    ScreenRegion r = s.find(target); 
    ....

错误-ClassLoader

我跟随了调试器,在open_core的类加载器上失败-请参见屏幕截图

更新资料

我在下面的每个Samuel答案中添加了POM分类器.我也尝试了setting the system property.仍然收到相同的错误.

还注意到以下错误-我已尝试将其尽可能减少.

Caused by: java.lang.UnsatisfiedLinkError: /private/var/folders/qp/.../libjniopencv_core.dylib: dlopen(/private/var/....../libjniopencv_core.dylib, 1): Library not loaded: @rpath/libopencv_core.2.4.dylib
  Referenced from: /private/var/.......libjniopencv_core.dylib
  Reason: no suitable image found.  Did find:
    /private/va.....77/./libopencv_core.2.4.dylib: malformed mach-o image: load command #12 length (0) too small in /private/var/fo......./libopencv_core.2.4.dylib  t java.lang.ClassLoader$NativeLibrary.load(Native Method)

解决方法:

答案基本上是README.md file,但我将在这里说明.您需要将platform.dependency系统属性设置为所需的平台(例如macosx-x86_64),或者将true设置为platform.dependencies,以获取所有平台的依赖关系.我不确定我们应该如何在JUnit Spring中设置它(应该在文档中),但是即使那样也不能与SBT一起使用,因此要解决这些情况,我们可以添加特定于平台的依赖项手动.由于您在Mac OS X上运行并且对使用OpenCV 2.4.9感兴趣,因此可以将以下其他依赖项添加到pom.xml文件中:

<dependency>
    <groupId>org.bytedeco.javacpp-presets</groupId>
    <artifactId>opencv</artifactId>
    <version>2.4.9-0.9</version>
    <classifier>macosx-x86_64</classifier>
</dependency>

标签:sikuli,opencv,classpath,unsatisfiedlinkerror,java
来源: https://codeday.me/bug/20191028/1950112.html