UnsatisfiedLinkError JNI

The old win32 project does not compile correctly on a 64-bit machine of a new perspective. I do not use 64 bit java.

package org.denkweise.coloredconsole;
public final class Console{
    static native void setColor(byte fg, byte bg);
}

sent to ColoredConsole32.h:

#include <jni.h>
JNIEXPORT void __cdecl Java_org_denkweise_coloredconsole_Console_setColor(JNIEnv *, jobject, jbyte, jbyte);

goes to ColoredConsole32.cpp:

#include "ColoredConsole32.h"
#include <windows.h>
JNIEXPORT void __cdecl Java_org_denkweise_coloredconsole_Console_setColor(JNIEnv * env, jobject ob, jbyte fg, jbyte bg) {
    /*stuff*/
}

and compile with mingw

g++ -D_JNI_IMPLEMENTATION_ -enable-stdcall-fixup -Wl,--kill-at ColoredConsole32.h -Ic:\jdk1.6.0_26\include -Ic:\jdk1.6.0_26\include\win32 -shared -o ColoredConsole.dll

System.loadLibrary works fine, but setColor throws

java.lang.UnsatisfiedLinkError: org.denkweise.coloredconsole.Console.setColor(BB)V

any sugestions?

+1
source share
1 answer

OK, there was my mistake:

The java method was static, but the second parameter of my c method was jobject instead of jclass.

make the method unstable solves my problem.

Hi

0
source

All Articles