简体   繁体   English

JNA java.lang.UnsatisfiedLinkError和找不到指定的模块

[英]JNA java.lang.UnsatisfiedLinkError and The specified module could not be found

I'm putting together a jar that will let me call commands only available to natives (the jar uses natives rather then the actual program). 我正在组装一个jar,它将让我调用仅对本机可用的命令(jar使用本机而不是实际程序)。 Now I ran into a problem, whenever I load the DLL. 每当我加载DLL时,我遇到了一个问题。 Here is the error: 这是错误:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'myDLL.dll': The specified module could not be found.

at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:194)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:283)
at com.sun.jna.Library$Handler.<init>(Library.java:142)
at com.sun.jna.Native.loadLibrary(Native.java:368)
at com.sun.jna.Native.loadLibrary(Native.java:353)
at src.NativeBridgeJar.<clinit>(NativeBridgeJar.java:6)
at src.Main.main(Main.java:6)

I don't why what the cause of this error would be. 我不知道为什么这个错误的原因是什么。 I made sure I set the native library path to the folder with the native. 我确保将本机库路径设置为具有本机的文件夹。 Does anyone have an idea? 有没有人有想法? Thanks in advanced! 提前致谢!

A) when you call Native.loadLibrary() , you may provide a shorthand name ("myDll"), a filename ("myDll.dll"), or the absolute path of the shared library ("c:/users/me/myDll.dll"). A)当您调用Native.loadLibrary() ,您可以提供简写名称(“myDll”),文件名(“myDll.dll”)或共享库的绝对路径(“c:/ users / me /将myDll.dll“)。

B) If you don't provide an absolute path to the library, you may tell it where to load the DLL by specifying jna.library.path , or making it available on java.library.path (there are other options described in the NativeLibrary javadoc ). B)如果您没有提供库的绝对路径,您可以通过指定jna.library.path或在java.library.path使用它来告诉它在何处加载DLL(还有其他选项描述在NativeLibrary javadoc )。

You should show JVM your dlls location. 您应该向JVM显示您的dll位置。 It can be done with -Djava.library.path=pathToDll VM argument 可以使用-Djava.library.path=pathToDll VM参数完成

I had the same problem until I put my .dll file into C:\\Windows\\System32 since it was a C++ DLL and had dependencies on Kernel32.dll and MSVCR100.dll in that folder. 我有同样的问题,直到我把我的.dll文件放到C:\\ Windows \\ System32,因为它是一个C ++ DLL并且依赖于该文件夹中的Kernel32.dll和MSVCR100.dll。 That seemed to work. 这似乎有效。

In addition to setting the path of dll using -Djava.library.path=pathToDll or System.setProperty("jna.library.path","pathToDll"); 除了使用-Djava.library.path=pathToDllSystem.setProperty("jna.library.path","pathToDll");设置dll的路径外System.setProperty("jna.library.path","pathToDll"); make sure the specific Visual C++ xxxx Redistributable Package is installed in your Windows(bcs the windows native libraries should have been built with specific VisualStudio xxxx) 确保在Windows中安装了特定的Visual C ++ xxxx Redistributable Package(bcs windows本机库应该使用特定的VisualStudio xxxx构建)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.UnsatisfiedLinkError:找不到指定的模块 - java.lang.UnsatisfiedLinkError: The specified module could not be found java.lang.UnsatisfiedLinkError: 找不到指定的程序 - java.lang.UnsatisfiedLinkError: The specified procedure could not be found 线程“ main”中的异常java.lang.UnsatisfiedLinkError:无法加载库“ mediainfo”:找不到指定的模块 - Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library 'mediainfo': The specified module could not be found 获取java.lang.UnsatisfiedLinkError:在Windows中使用tesseract时找不到指定的模块 - getting java.lang.UnsatisfiedLinkError: The specified module could not be found while working with tesseract in windows java.lang.UnsatisfiedLinkError:无法加载库“ TSCLIB”:找不到指定的模块 - java.lang.UnsatisfiedLinkError: Unable to load library 'TSCLIB': The specified module could not be found HTTP状态500-处理程序处理失败; 嵌套的异常是java.lang.UnsatisfiedLinkError:找不到指定的模块 - HTTP Status 500 - Handler processing failed; nested exception is java.lang.UnsatisfiedLinkError: The specified module could not be found java.lang.UnsatisfiedLinkError:无法加载库“ jpbc-pbc”:找不到指定的模块 - java.lang.UnsatisfiedLinkError: Unable to load library 'jpbc-pbc': The specified module could not be found 线程“主”中的异常java.lang.UnsatisfiedLinkError:无法加载库“ TableauExtract”:找不到指定的模块 - Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library 'TableauExtract': The specified module could not be found Windows中的Tess4j问题:java.lang.UnsatisfiedLinkError:在instance.doOCR(imageFile)中找不到指定的模块 - Tess4j Issue in Windows: java.lang.UnsatisfiedLinkError: The specified module could not be found in instance.doOCR(imageFile) 线程“main”中的异常java.lang.UnsatisfiedLinkError:无法加载库'libtesseract302':找不到指定的模块 - Exception in thread “main” java.lang.UnsatisfiedLinkError: Unable to load library 'libtesseract302': The specified module could not be found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM