在cygwin中编译时出错 [英] Error when compiling in cygwin

查看:259
本文介绍了在cygwin中编译时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  gcc prog.c -o prog -IC :/ Program Files / Java / jdk1.8.0_25 / include-IC:/ Program Files / Java / jdk1.8.0_25 / include / win32

错误:未知类型名称'_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!
}


解决方案

问题:


在Linux和Cygwin下构建基于JNI的Java应用程序



Cygwin Builds的Java mods



在Cygwin下,我们创建的JNI(Java Native Interface)库名为JNILibrary不会构建,因为gcc不知道类型__int64。如果你看到这样的问题,你会知道你遇到了这个问题:



构建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:error:在jlong​​之前解析错误。
/cygdrive/c/j2sdk1.4.2_12/include/win32/jni_md.h:16:warning:数据定义没有类型或存储类



如果你打这个,然后你需要编辑/cygdrive/c/j2sdk1.4.2_12/include/win32/jni_md.h并改变这些行:

  typedef long jint; 
typedef __int64 jlong​​;
typedef signed char jbyte;

到:

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


您也可以尝试以下操作:


  1. 之前添加 #include< stdint.h> < jni.h>


  2. p>添加java编译器标志: -D__int64 = int64_t



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.

Code

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

You could also try the following:

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

  2. Add the java compiler flag: -D__int64=int64_t

这篇关于在cygwin中编译时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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