خرید بک لینک

Vote count: 0

I'm trying to develop a java program that uses c++ code. For this purpose, I'm using a 32-bit mingw and a 32-bits jre (version 1.8.0_77).

I have problems trying to load the *.dll. (I haven't tried to run any method yet)

This is the class where I have declared the native method:

public class JniImports {
    static{
        System.loadLibrary("hello");
    }

    public int test(int n){
        retu testJava(n);
    }

    private native int testJava(int n);
}

And this is the Main method:

public class Main {
    public static void main(String[] args) {
        JniImports a = new JniImports();
    }
}

The c-header file has been generated by the javah tool, so I'm sure that's ok. Anyway, as I have said, I have not tried to execute any method.

If I use a 64-bits JRE, the error is that it can't load a 32-bit dll on a 64-bit jre:

java.lang.UnsatisfiedLinkError: D:wstestjnijnihello.dll Can't load IA 32-bit .dll on a AMD 64-bit platform

I think this error shows that, in this case, the JRE finds the *.dll.

If I use a 32-bits JRE, the error is that it can't find the *.dll:

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

If I use a 32-bits JRE and I remove the hello.dll library, this is the error: java.lang.UnsatisfiedLinkError: no hello in java.library.path

So, compiling the c++ code with a 32-bit compiler and using a 32-bit JRE, it can find the dll, but it crashes anyway.

I have also tried to compile the c++ code in debug mode (with -g flag) and it also crashes.

I'm sure that the dll is in the correct place, because if I copy-paste the path displayed in the error log in the window's explorer path bar, it takes me to the folder where the dll is, and I'm sure that its name is "hello.dll".

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 6 ارديبهشت 1395 ساعت: 1:32

صفحه بندی