试图使用OpenCV可移植的java应用程序(Executable Jar)。得到不满意的链接错误 [英] Trying to make java application (Executable Jar) that uses OpenCV portable. Getting unsatisfied link error

查看:361
本文介绍了试图使用OpenCV可移植的java应用程序(Executable Jar)。得到不满意的链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经申请从网络摄像头抓取视频并使用OpenCV和JavaCV检测动作。我正在尝试使用eclipse导出为可执行jar。该程序在eclipse中运行正常,就像我编写程序的计算机上的exe jar一样。



我想要完成的是让exe jar在没有安装OpenCV的计算机上运行。基本上我会考虑一个便携式应用程序。当我在除了JRE之外没有安装任何东西的另一台计算机上运行exe jar时,我得到了下面看到的不满意的链接错误。

 线程视频线程中的异常java.lang.UnsatisfiedLinkError:C:\ Users \ JohnD\ AppData \ Local \ Temp \ javacpp91062429652918 \ jniopencv_core.dll:无法找到依赖库
at java.lang.ClassLoader $ NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(Unknown Source)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(未知来源)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com。 googlecode.javacpp.Loader.loadLibrary(Loader.java:566)
at com.googlecode.javacpp.Loader.load(Loader.java:489)
at com.googlecode.javacpp.Loader.load( Loader.java:431)
at com.googlecode.javacv.cpp.opencv_core。< clinit>(openc v_core.java:136)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.googlecode.javacpp.Loader .load(Loader.java:453)
at com.googlecode.javacv.cpp.opencv_imgproc。< clinit>(opencv_imgproc.java:97)
at java.lang.Class.forName0(Native Method) )
at java.lang.Class.forName(Unknown Source)
at com.googlecode.javacpp.Loader.load(Loader.java:453)
at com.googlecode.javacv.cpp .opencv_highgui。< clinit>(opencv_highgui.java:85)
at com.googlecode.javacv.OpenCVFrameGrabber.start(OpenCVFrameGrabber.java:174)
at VideoPanel.run(VideoPanel.java:163)
at java.lang.Thread.run(Unknown Source)
引起:java.lang.UnsatisfiedLinkError:java.library.path中没有opencv_core244
at java.lang.ClassLoader.loadLibrary(未知来源)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at c om.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
at com.googlecode.javacpp.Loader.load(Loader.java:481)
... 13 more

我已经找到了解决我做错的方法。我遇到的大多数主题都是不满意的链接错误,比如我收到的链接错误,一直试图让它在IDE中第一次运行,这不是这里的情况。我认为我的依赖项在构建路径中的库中是正确的,因为当我在安装了所有内容的计算机上时,我可以让它完美地运行,但我仍然认为我在构建时出错了。



我想再试一下,以便Jar可以在没有安装OpenCV / JavaCV的计算机上运行。任何帮助将不胜感激。

解决方案

如果目标机器中没有安装 opencv ,那么需要提供必要的opencv的dll文件并设置相应的库路径, opencv javacv

例如:

  jar yourapp.jar -Djava.library.path = / path / to / OpenCV / library

也查看此答案


I have made a application to grab video from a webcam and detect motion using OpenCV and JavaCV. I am trying to export as an executable jar using eclipse. The program runs fine in eclipse as does the exe jar on the computer I coded the program on.

What I am trying to accomplish is to make the exe Jar run on computers that don't have OpenCV installed. Basically what I would consider a portable application. When I run the exe jar on a different computer that has nothing installed other than the JRE I get unsatisfied link errors seen below.

Exception in thread "Video Thread" java.lang.UnsatisfiedLinkError: C:\Users\JohnD\AppData\Local\Temp\javacpp91062429652918\jniopencv_core.dll: Can't find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(Unknown Source)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:566)
    at com.googlecode.javacpp.Loader.load(Loader.java:489)
    at com.googlecode.javacpp.Loader.load(Loader.java:431)
    at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:136)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.googlecode.javacpp.Loader.load(Loader.java:453)
    at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.googlecode.javacpp.Loader.load(Loader.java:453)
    at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
    at com.googlecode.javacv.OpenCVFrameGrabber.start(OpenCVFrameGrabber.java:174)
    at VideoPanel.run(VideoPanel.java:163)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: no opencv_core244 in java.library.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
    at com.googlecode.javacpp.Loader.load(Loader.java:481)
    ... 13 more

I have looked for a solution to what I am doing wrong. Most of the topics I have come across with unsatisfied link errors like the ones I am receiving have been trying to get it to run the first time through within there IDE, which is not the case here. I would think my dependencies are correct in the libraries in the build path since I can get it to run perfectly when I am on the computer that has everything installed but I still believe I am doing something wrong with the build.

Again I am trying to make it so the Jar can run on computers where OpenCV/JavaCV is not installed. Any help would be greatly appreciated.

解决方案

If opencv is not installed in the target machine, than you need to deliver the necessary opencv's dll file and set the corresponding library path, opencv is a precondition of javacv

for example:

jar yourapp.jar -Djava.library.path="/path/to/OpenCV/library"

also check this answer

这篇关于试图使用OpenCV可移植的java应用程序(Executable Jar)。得到不满意的链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆