开发者

Another JNI UnsatisfiedLinkError DLL problem

I've read lots of posts about this, but none address my problem.

I have a very small DLL that allows a Java process to send windows messages. It simply calls

    FindWindowEx(...)
    SendMessage(...)

I have compiled that with VS2005 and linked with /MT and all's fine, but if I try to make my DLL depend on MSVCRT and link with /MD then I get the unsatisfi开发者_开发知识库ed link error.

java.lang.UnsatisfiedLinkError: MyDll.dll: Can't find dependent libraries

According to depends.exe it has two missing DLLs, GPSVC.DLL and IESHIMS.DLL. The first exists in c:\windows\system32 and the second is in a winsxs path. There are LOADS of other DLLs loaded from c:\windows\system32 and GPSVC.DLL is an odd one in that even as admin on my win7x64 machine, I cannot run depends on that - it says it's not found...

Anyway, I tried forcing a load of both of those DLLs in my Java by (simplified - I'm not in control of java.library.path)

    Field field = ClassLoader.class.getDeclaredField("usr_paths");
    field.setAccessible(true);
    String[] paths = (String[]) field.get(null);
    String[] tmp = new String[paths.length + 2];
    System.arraycopy(paths, 0, tmp, 0, paths.length);
    tmp[paths.length] = "c:/windows/system32";
    tmp[paths.length + 1] = "c:/Windows/winsxs/amd64_microsoft-windows-ie-ieshims_31bf3856ad364e35_8.0.7601.17514_none_c06d7c9c27da8591";
    field.set(null, tmp);

but that made no difference. I can fallback to make it statically linked, but I'd rather not.

Any ideas on what I can try next? Antony


Well, I´m using Visual Studio 2010 but it could work on 2005 too.

You could try configuring the VC compiler using vcvarsall.bat that you can find in ProgramFiles in /MicrosoftVisualStudio20xx/VC .

You have only to launch vsvarsall.bat in Command Line with one of these options: x86 or ia64 or x86_amd64 or x86_ia64. I don´t know if it will help but it could be one of the problems that VC compiler is not configured to work with 64 bit machine.

When I´m working with JNI I use command line to compile the code and I had to configure the compiler on 64 bit machine.

Or you could pobably try to compile it via Command Line. Here is my favourite tutorial http://www.ibm.com/developerworks/java/tutorials/j-jni/index.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜