Hallo,
ich arbeite mich gerade durch das Kapitel über JNI aus dem Buch Java ist auch eine Insel – 24 Java Native Interface (JNI)
Jedoch hab ich da bisher so meine Schwierigkeiten die DLL Datei zu compilieren. Die Headerdatei hab ich mit javah bekommen. Meine .c Datei sieht wie folgt aus:
Compilieren möchte ich das über den GCC Compiler. Hab da bisher folgenden Befehl:
In dem Java Ordner befindet sich halt die jni.h. Wenn ich den compiler allerdings starte, bekomme ich einen ganzen Berg von Fehlermeldungen. Hier nur mal ein Ausschnitt davon:
Weiß jemand was ich da falsch mache?
gruß seux
ich arbeite mich gerade durch das Kapitel über JNI aus dem Buch Java ist auch eine Insel – 24 Java Native Interface (JNI)
Jedoch hab ich da bisher so meine Schwierigkeiten die DLL Datei zu compilieren. Die Headerdatei hab ich mit javah bekommen. Meine .c Datei sieht wie folgt aus:
Java:
#include <jni.h>
#include "StrLen.h"
#include <stdio.h>
JNIEXPORT jint JNICALL Java_com_javatutor_jni_StrLen_strlen( JNIEnv *env, jclass clazz, jstring s )
{
printf( "Hallo Java-Freunde!\n" );
return 0;
}
Compilieren möchte ich das über den GCC Compiler. Hab da bisher folgenden Befehl:
Code:
gcc strlen.c -I D:\Libraries\Java -o strlen.dll
Code:
jni.h:1901: error: `jint' declared as function returning a function
jni.h:1901: warning: data definition has no type or storage class
jni.h:1903: error: syntax error before '*' token
jni.h:1903: error: `jint' declared as function returning a function
jni.h:1903: warning: data definition has no type or storage class
jni.h:1904: error: syntax error before '}' token
jni.h:1934: error: syntax error before "jint"
jni.h:1935: warning: data definition has no type or storage class
jni.h:1937: error: syntax error before "jint"
jni.h:1938: warning: data definition has no type or storage class
jni.h:1940: error: syntax error before "jint"
jni.h:1941: error: syntax error before "jsize"
jni.h:1941: warning: data definition has no type or storage class
jni.h:1944: error: syntax error before "jint"
jni.h:1945: warning: data definition has no type or storage class
jni.h:1947: error: syntax error before "void"
jni.h:1948: warning: data definition has no type or storage class
In file included from strlen.c:2:
StrLen.h:15: error: syntax error before "jint"
StrLen.h:16: warning: data definition has no type or storage class
strlen.c:4: error: syntax error before "jint"
strlen.c:8:2: warning: no newline at end of file
Weiß jemand was ich da falsch mache?
gruß seux