gpt4 book ai didi

java-native-interface - 在 cygwin 中编译时出错——错误 : unknown type name '_int64' -- (jni. h)

转载 作者:行者123 更新时间:2023-12-04 00:09:43 26 4
gpt4 key购买 nike

运行以下命令后,我收到一个错误

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'
请告诉我如何修复此错误。
代码
#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!");
}

最佳答案

以下应该有助于缓解这个问题:

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 class

If 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;


您还可以尝试以下操作:
  • 添加 #include <stdint.h>之前 #include <jni.h>在标题中...
  • 添加java编译器标志:-D__int64=int64_t
  • 关于java-native-interface - 在 cygwin 中编译时出错——错误 : unknown type name '_int64' -- (jni. h),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27891478/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com