在 cygwin 中编译时出错 -- 错误:未知类型名称 '_int64' -- (jni.h) [英] Error when compiling in cygwin -- error: unknown type name '_int64' -- (jni.h)

查看:33
本文介绍了在 cygwin 中编译时出错 -- 错误:未知类型名称 '_int64' -- (jni.h)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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:

在 Cygwin 下,我们创建的名为 JNILibrary 的 JNI(Java 原生接口)库无法构建,因为 gcc 不知道类型__int64".如果您看到这样的内容,您就会知道您遇到了问题:

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:

构建 JNILibrary 类和标头....在/cygdrive/c/j2sdk1.4.2_12/include/jni.h:27 包含的文件中,来自 JNICrunch-common.h:25,
来自 JNICrunchHWInfo.c:31:
/cygdrive/c/j2sdk1.4.2_12/include/win32/jni_md.h:16:错误:jlong​​"之前的解析错误./cygdrive/c/j2sdk1.4.2_12/include/win32/jni_md.h:16:警告:数据定义没有类型或存储类

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

如果你确实点击了这个,那么你需要编辑/cygdrive/c/j2sdk1.4.2_12/include/win32/jni_md.h 并更改这些行:

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;

到:

typedef long jint;
#ifdef __GNUC__
typedef long long jlong;
#else
typedef __int64 jlong;
#endif
typedef signed char jbyte;

您也可以尝试以下方法:

You could also try the following:

  1. 在标题中的 #include <jni.h> 之前添加 #include <stdint.h>...

  1. Add #include <stdint.h> before #include <jni.h> in the header... or

添加java编译器标志:-D__int64=int64_t

Add the java compiler flag: -D__int64=int64_t

这篇关于在 cygwin 中编译时出错 -- 错误:未知类型名称 '_int64' -- (jni.h)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆