本文介绍了UnsatisfiedLinkError:找不到指定的过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用C ++编写一些JNI代码,用于从Windows XP上的applet调用。我已经能够成功运行applet并加载和调用JNI库,甚至可以在其他DLL中调用函数。通过设置PATH系统环境变量来包含我所有DLL所在的目录,我得到了这个工作。

I'm writing some JNI code in C++ to be called from an applet on Windows XP. I've been able to successfully run the applet and have the JNI library loaded and called, even going so far as having it call functions in other DLLs. I got this working by setting up the PATH system environment variable to include the directory all of my DLLs are in.

所以,问题是我添加了另一个调用使用新的外部DLL,并在加载库时突然抛出UnsatisfiedLinkError。消息是:'找不到指定的过程'。这似乎不是一个缺少依赖DLL的问题,因为我可以删除一个从属DLL并获得有关从属DLL丢失的不同消息。从我在网上找到的内容来看,似乎这个消息意味着DLL中缺少本机Java函数实现,但奇怪的是它没有这些额外的代码就可以正常工作。

So, the problem, is that I add another call that uses a new external DLL, and suddenly when loading the library, an UnsatisfiedLinkError is thrown. The message is: 'The specified procedure could not be found'. This doesn't seem to be a problem with a missing dependent DLL, because I can remove a dependent DLL and get a different message about dependent DLL missing. From what I've been able to find online, it appears that this message means that a native Java function implementation is missing from the DLL, but it's odd that it works fine without this extra bit of code.

有谁知道这可能导致什么?什么类型的东西可以为UnsatisifedLinkError提供'找不到指定的过程'消息?

Does anyone know what might be causing this? What kinds of things can give a 'The specified procedure could not be found' messages for an UnsatisifedLinkError?

推荐答案

我想出了问题。这真是太过分了。对于UnsatisfiedLinkError,无法找到指定的过程消息表示无法找到根dll或依赖dll 中的函数。在JNI情况下,最可能的原因是本机JNI函数未正确导出。但是,如果加载了一个依赖DLL并且该DLL缺少其父级所需的函数,这显然会发生。

I figured out the problem. This was a doozy. The message "The specified procedure could not be found" for UnsatisfiedLinkError indicates that a function in the root dll or in a dependent dll could not be found. The most likely cause of this in a JNI situation is that the native JNI function is not exported correctly. But this can apparently happen if a dependent DLL is loaded and that DLL is missing a function required by its parent.

举例来说,我们有一个名为input的库。 DLL。 DLL搜索顺序始终首先查看应用程序目录,最后查找PATH目录。过去,我们总是在与input.dll相同的目录中运行可执行文件。但是,Windows系统目录中还有另一个input.dll(位于DLL搜索顺序的中间)。因此,当从Java applet运行它时,如果我在applet中包含上述代码,导致input.dll被加载,它将从系统目录加载input.dll。因为我们的代码期望input.dll中的某些函数不存在(因为它是一个不同的DLL),所以加载失败并显示有关缺少过程的错误消息。不是因为JNI函数导出错误,而是因为加载了错误的依赖DLL并且它没有预期的函数。

By way of example, we have a library named input.dll. The DLL search order is to always look in the application directory first and the PATH directories last. In the past, we always ran executables from the same directory as input.dll. However, there is another input.dll in the windows system directory (which is in the middle of the DLL search order). So when running this from a java applet, if I include the code described above in the applet, which causes input.dll to be loaded, it loads the input.dll from the system directory. Because our code is expecting certain functions in input.dll which aren't there (because it's a different DLL) the load fails with an error message about missing procedures. Not because the JNI functions are exported wrong, but because the wrong dependent DLL was loaded and it didn't have the expected functions in it.

这篇关于UnsatisfiedLinkError:找不到指定的过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 20:29
查看更多