After I run the following command, then I receive an error
gcc prog.c -o prog -I"C:/Program Files/Java/jdk1.8.0_25/include" -I"C:/Program Files/Java/jdk1.8.0_25/include/win32"
error: unknown type name '_int64'
Please tell me how to fix this error.
#include <string.h>
#include <jni.h>
jstring Java_com_mindtherobot_samples_ndkfoo_NdkFooActivity_invokeNativeFunction(
JNIEnv* env, jobject javaThis) {
return (*env)->NewStringUTF(env, "Hello from native code!");
}
the following should help alleviate this issue:
Building JNI-based Java Applications under Linux and Cygwin
Java mods for Cygwin Builds
Under Cygwin, the JNI (Java Native Interface) library we created called JNILibrary doesn’t build because gcc doesn’t know about the type “__int64″. You’ll know you hit the problem if you see something like this:
Building JNILibrary class and header…. In file included from /cygdrive/c/j2sdk1.4.2_12/include/jni.h:27, from JNICrunch-common.h:25,
from JNICrunchHWInfo.c:31:
/cygdrive/c/j2sdk1.4.2_12/include/win32/jni_md.h:16: error: parse error before “jlong”. /cygdrive/c/j2sdk1.4.2_12/include/win32/jni_md.h:16: warning: data definition has no type or storage classIf you do hit this, then you need to edit /cygdrive/c/j2sdk1.4.2_12/include/win32/jni_md.h and change these lines:
typedef long jint; typedef __int64 jlong; typedef signed char jbyte;
to:
typedef long jint; #ifdef __GNUC__ typedef long long jlong; #else typedef __int64 jlong; #endif typedef signed char jbyte;
You could also try the following:
Add #include <stdint.h>
before #include <jni.h>
in the header... or
Add the java compiler flag: -D__int64=int64_t
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With