JavaCV 给出 java.lang.UnsatisfiedLinkError

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6784740/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 17:15:39  来源:igfitidea点击:

JavaCV giving java.lang.UnsatisfiedLinkError

javaopencvnativelinker-errors

提问by Cihad Turhan

Alright, you may say "use google search for this, there are millions of them". However, I almost spent all day just to run following code but every since I tried I got java.lang.UnsatisfiedLinkError: C:\Users\hp\AppData\Local\Temp\jniopencv_core2477828805078034839.dll: Can't find dependent librarieserror which drives me mad.

好吧,你可能会说“使用谷歌搜索,有数百万个”。但是,我几乎花了一整天的时间来运行以下代码,但是自从我尝试后,我得到了java.lang.UnsatisfiedLinkError: C:\Users\hp\AppData\Local\Temp\jniopencv_core2477828805078034839.dll: Can't finddependent librarieserror which让我发疯。

I found javacv-binfolder which includes javacpp.jar, javacv.jar, javacv-windows-x86.jar, javacv-windows-x86_64.jar.

我找到了javacv-bin文件夹,其中包括javacpp.jar、javacv.jar、javacv-windows-x86.jar、javacv-windows-x86_64.jar

In Netbeans, I opened project properties and I added them into the libraries

在 Netbeans 中,我打开了项目属性并将它们添加到库中

I found OpenCV2.3folder, copied and pasted it into C:\ directory.

我找到了OpenCV2.3文件夹,将其复制并粘贴到 C:\ 目录中。

I added C:\OpenCV2.3\build\bin; C:\OpenCV2.3\build\x86\vc10\bin; C:\OpenCV2.3\build\x64\vc10\bin;in the PATH.

我添加了C:\OpenCV2.3\build\bin; C:\OpenCV2.3\build\x86\vc10\bin; C:\OpenCV2.3\build\x64\vc10\bin; 路径中。

And I believe nothing to do left. However, every since I tried I got the same error. I'm exhausted please someone help me.

我相信没什么可做的。但是,自从我尝试后,我都遇到了同样的错误。我累了请有人帮助我。

And last to say, I have both 32-bitand 64-bitJDKs so I tried both compilers but it's no use.

最后要说的是,我有32 位64 位JDK,所以我尝试了两种编译器,但没有用。

import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;

public class Smoother {
    public static void main(String[] args) {
        smooth("filename0.png");
    }
    public static void smooth(String filename) {
        System.out.println("java.library.path="+System.getProperty("java.library.path"));
        IplImage image = cvLoadImage(filename);
        if (image != null) {
            cvSmooth(image, image, CV_GAUSSIAN, 3);
            cvSaveImage(filename, image);
            cvReleaseImage(image);
        }
    }
}

采纳答案by Aravind

I had the same problem as you did. Assuming your openCV folder location is C:\OpenCV2.3, here is what to do.

我和你有同样的问题。假设您的 openCV 文件夹位置是C:\OpenCV2.3,这是要执行的操作。

  1. Create path and classpath variables under both user AND system environment variables.

  2. Append this to all four variables(Assuming you have the latest version of openCV2.3): C:\OpenCV2.3\build\bin;C:\OpenCV2.3\build\x64\mingw\bin;C:\OpenCV2.3\build\x64\vc9\bin;C:\OpenCV2.3\build\x64\vc10\bin;C:\OpenCV2.3\build\x86\mingw\bin;C:\OpenCV2.3\build\x86\vc9\bin;C:\OpenCV2.3\build\x86\vc10\bin;

  1. 在用户和系统环境变量下创建路径和类路径变量。

  2. 将此附加到所有四个变量(假设您拥有最新版本的 openCV2.3): C:\OpenCV2.3\build\bin;C:\OpenCV2.3\build\x64\mingw\bin;C:\OpenCV2.3\build\x64\vc9\bin;C:\OpenCV2.3\build\x64\vc10\bin;C:\OpenCV2.3\build\x86\mingw\bin;C:\OpenCV2.3\build\x86\vc9\bin;C:\OpenCV2.3\build\x86\vc10\bin;

Hope it helps! Aravind

希望能帮助到你!阿拉文

回答by ratfury

Two Tips:

两个提示:

  • You can't mix 64 and x86 libraries in the pathes!
  • restart Eclipse
  • 您不能在路径中混合使用 64 和 x86 库!
  • 重启 Eclipse

回答by cuneytyvz

If anybody have this problem and updating system path and class path didn't solve, rename your OpenCv2.3.1 directory to "opencv". It did solve my problem.

如果有人遇到这个问题并且更新系统路径和类路径没有解决,请将您的 OpenCv2.3.1 目录重命名为“opencv”。它确实解决了我的问题。

回答by buch11

I have never worked with OpenCV ,but somehow I made my JNI code work.Have you generated the .dll or it comes with the package? And check this post ,it may Ohelp JNI error while calling a C subroutine... One more suggestion try putting your dll in system32 folder and then load it manually using System.load(path/to/dll) method...Happy coding

我从来没有使用过 OpenCV,但不知何故我让我的 JNI 代码工作。你生成了 .dll 还是它随包一起提供的?并检查这篇文章,它可能会在调用 C 子例程时出现Ohelp JNI 错误......还有一个建议尝试将你的 dll 放在 system32 文件夹中,然后使用 System.load(path/to/dll) 方法手动加载它......快乐编码