Java加载DLL,该DLL从JNI中的另一个DLL导出方法

Java loading a DLL that export methods from another DLL in JNI

本文关键字:DLL 另一个 方法 JNI 加载 Java      更新时间:2023-10-16

我做了一个从JNI中的另一个DLL导出的DLL。

    JNIEXPORT bool JNICALL getIsWordInPhonemListFR(const char* word)
{
    isWordInPhonemListFR method = NULL;
    BOOL fRunTimeLinkSuccess = FALSE;
    HINSTANCE hGetProcIDDLL = LoadLibrary(L"PhoneticEngineFR2.dll");
    if (!hGetProcIDDLL) {
        std::cout << "kcould not load the dynamic library" << std::endl;
    }else{
        method = (isWordInPhonemListFR)GetProcAddress(hGetProcIDDLL, "isWordInPhonemListFR");
    }
    return method(word);
}

system。加载Java中没有任何错误,但是当我想使用本机方法时,我会得到

java.lang.unsatisfiedlinkerror:

两个dll在我的项目中的同一文件夹中。在Visual Studio工作时工作正常,但是JNI的出口出现了问题。JNI on Load也没有触发Java。

谢谢

我很愚蠢,我在所有JNI导出方法上都有一个名称空间。因此,他们没有被执行。现在起作用。