Linux下实现JNI期间发生的错误……【未解决】

  万能的博客园啊……希望发完这个问题记录后能尽快发现自己的错误%>_<%

问题描述:

  在linux下通过gcc命令编译c文件生成动态链接库.so文件时报错。之前命令内导入了jni.h和jni_md.h所在路径,报错;之后将这两个头文件复制到/usr/include/路径下,

导入,仍报错。

  检查了一下JAVA_HOME路径、java、javac命令都能正常运行,普通的.c文件也能正常编译。根据报错的提示来看是.h文件中的jint、jbyte...未定义。。。不过根据我

浅薄的认知,这些变量不就在jni.h里定义的么……真是头痛。。。

[email protected]:~/Documents/temp$ gcc -shared -I /usr/include/ JniTest.c -o libHello.so

In file included from /usr/include/jni_md.h:32:0,
                 from /usr/include/jni.h:45,
                 from JniTest.h:2,
                 from JniTest.c:2:
/usr/include/jawt.h:141:5: error: unknown type name ‘jint’
     jint x;
     ^
/usr/include/jawt.h:142:5: error: unknown type name ‘jint’
     jint y;
     ^
/usr/include/jawt.h:143:5: error: unknown type name ‘jint’
     jint width;
     ^
/usr/include/jawt.h:144:5: error: unknown type name ‘jint’
     jint height;
     ^
/usr/include/jawt.h:167:5: error: unknown type name ‘jint’
     jint clipSize;
     ^
/usr/include/jawt.h:190:5: error: unknown type name ‘JNIEnv’
     JNIEnv* env;
     ^
/usr/include/jawt.h:192:5: error: unknown type name ‘jobject’
     jobject target;
     ^
/usr/include/jawt.h:208:5: error: expected specifier-qualifier-list before ‘jint’
     jint (JNICALL *Lock)
     ^
/usr/include/jawt.h:242:5: error: unknown type name ‘jint’
     jint version;
     ^
/usr/include/jawt.h:252:35: error: expected ‘)’ before ‘*’ token
     JAWT_DrawingSurface* (JNICALL *GetDrawingSurface)
                                   ^
/usr/include/jawt.h:257:19: error: expected ‘)’ before ‘*’ token
     void (JNICALL *FreeDrawingSurface)
                   ^
/usr/include/jawt.h:263:19: error: expected ‘)’ before ‘*’ token
     void (JNICALL *Lock)(JNIEnv* env);
                   ^
/usr/include/jawt.h:268:19: error: expected ‘)’ before ‘*’ token
     void (JNICALL *Unlock)(JNIEnv* env);
                   ^
/usr/include/jawt.h:280:5: error: expected ‘;’ before ‘jobject’
     jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo);
     ^
/usr/include/jawt.h:288:1: error: unknown type name ‘_JNI_IMPORT_OR_EXPORT_’
 _JNI_IMPORT_OR_EXPORT_
 ^
/usr/include/jawt.h:289:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘JNICALL’
 jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt);
          ^
/usr/include/jawt.h:289:10: error: unknown type name ‘JNICALL’
In file included from /usr/include/jni.h:45:0,
                 from JniTest.h:2,
                 from JniTest.c:2:
/usr/include/jni_md.h:53:18: error: expected ‘)’ before ‘*’ token
     int (JNICALL *GetAWTColor)(JAWT_DrawingSurface* ds,
                  ^
In file included from JniTest.h:2:0,
                 from JniTest.c:2:
/usr/include/jni.h:63:1: error: unknown type name ‘jint’
 typedef jint            jsize;
 ^
/usr/include/jni.h:122:5: error: unknown type name ‘jbyte’
     jbyte    b;
     ^
/usr/include/jni.h:125:5: error: unknown type name ‘jint’
     jint     i;
     ^
/usr/include/jni.h:126:5: error: unknown type name ‘jlong’
     jlong    j;
     ^
/usr/include/jni.h:220:5: error: expected specifier-qualifier-list before ‘jint’
     jint (JNICALL *GetVersion)(JNIEnv *env);
     ^
/usr/include/jni.h:1869:5: error: unknown type name ‘jint’
     jint version;
     ^
/usr/include/jni.h:1871:5: error: unknown type name ‘jint’
     jint nOptions;
     ^
/usr/include/jni.h:1877:5: error: unknown type name ‘jint’
     jint version;
     ^
/usr/include/jni.h:1895:5: error: expected specifier-qualifier-list before ‘jint’
     jint (JNICALL *DestroyJavaVM)(JavaVM *vm);
     ^
/usr/include/jni.h:1934:1: error: unknown type name ‘JNIIMPORT’
 _JNI_IMPORT_OR_EXPORT_ jint JNICALL
 ^
/usr/include/jni.h:1934:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘JNICALL’
 _JNI_IMPORT_OR_EXPORT_ jint JNICALL
                             ^
/usr/include/jni.h:1934:29: error: unknown type name ‘JNICALL’
/usr/include/jni.h:1937:1: error: unknown type name ‘JNIIMPORT’
 _JNI_IMPORT_OR_EXPORT_ jint JNICALL
 ^
/usr/include/jni.h:1937:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘JNICALL’
 _JNI_IMPORT_OR_EXPORT_ jint JNICALL
                             ^
/usr/include/jni.h:1937:29: error: unknown type name ‘JNICALL’
/usr/include/jni.h:1940:1: error: unknown type name ‘JNIIMPORT’
 _JNI_IMPORT_OR_EXPORT_ jint JNICALL
 ^
/usr/include/jni.h:1940:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘JNICALL’
 _JNI_IMPORT_OR_EXPORT_ jint JNICALL
                             ^
/usr/include/jni.h:1940:29: error: unknown type name ‘JNICALL’
/usr/include/jni.h:1944:1: error: unknown type name ‘JNIEXPORT’
 JNIEXPORT jint JNICALL
 ^
/usr/include/jni.h:1944:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘JNICALL’
 JNIEXPORT jint JNICALL
                ^
/usr/include/jni.h:1944:16: error: unknown type name ‘JNICALL’
/usr/include/jni.h:1947:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
 JNIEXPORT void JNICALL
           ^
In file included from JniTest.c:2:0:
JniTest.h:15:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
 JNIEXPORT void JNICALL Java_JniTest_output
           ^
JniTest.c:4:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’
 JNIEXPORT void JNICALL Java_JniTest_output(JNIEnv * env, jobject obj)
           ^
时间: 2025-01-06 14:00:54

Linux下实现JNI期间发生的错误……【未解决】的相关文章

linux下java unrecognized class file version错误的解决

[email protected] javaPC]# java HelloWorldException in thread “main” java.lang.ClassFormatError: HelloWorld (unrecognized class file version)at java.lang.VMClassLoader.defineClass(libgcj.so.7rh)at java.lang.ClassLoader.defineClass(libgcj.so.7rh)at ja

[转]Linux下使用JNI的常见问题及解决方案

Linux下使用JNI的常见问题及解决方案 转载地址:http://www.cnblogs.com/javawebsoa/p/3220069.html 我碰到的问题是bad value 参考这里解决的 linux生成动态库时遇到了relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC错误. 由于我的系统是AMD64位的,所以需要在编译的时候

linux下转格式函数iconv段错误

今天将windows代码移植到Linux下,其中用到了Unicode转char的函数,被坑了一会,相关函数及编码格式,Linux与windows不同,有几点需要注意: 1.wchar_t 在Linux下占用4个字节,在windows下占2个字节: 2.Linux默认的文本编码方式是UTF-8:Linux终端汉字显示的设置方式:vi /etc/sysconfig/i18n: 设置LANG="en_US.UTF-8"或者LANG="zh_CN.UTF-8": 3.ico

windows linux 下安装mysql 报1045 等错误

曾经在windows 下安装mysql 没怎么出现过问题.而在linux下安装的时候出现了一些问题,昨天在windows 安装的时候也出现了1045 错误.就个人经历来看这个问题就是 root用户password的问题,所以将解决的方式总结例如以下: 一.mysql登录报 1045 错误 mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (us

转载:Linux下执行SVN命令时提示错误:Valid UTF-8 data

在Linux下执行svn add *时出现如下错误: svn:  Valid UTF-8  data(hex: 4b)followed by invalid UTF-8 sequence(hex:  fc 63 68  65) 出现这个错误是因为svn库里有文件的名字不是utf-8编码的,这种情况对于中文来说很常见.比如在自己的windows上建了一个中文名字的文件,就会使这种情况. 几经周折,才找到解决办法: 首先,执行命令: ls * | file -/dev/stdin:  ISO-885

GDI+中发生一般性错误的解决办法(转载)

今天在开发.net引用程序中,需要System.Drawing.Image.Save 创建图片,debug的时候程序一切正常,可是发布到IIS后缺提示出现"GDI+中发生一般性错误"的异常.于是开始"摆渡",并寻找到了解决办法:赋予 NETWORK SERVICE 帐户以写权限. 以下为晚上寻找到的资料: 在开发.NET应用中,使用 System.Drawing.Image.Save 方法而导致"GDI+ 中发生一般性错误"的发生,通常有以下三种

linux下安装Oracle时交换空间不足的解决方法

摘:linux下安装Oracle时交换空间不足的解决方法 linux上安装Oracle时交换空间不足的解决办法 增加交换空间有两种方法: 严格的说,在系统安装完后只有一种方法可以增加swap,那就是本文的第二种方法, 至于第一种方法应该是安装系统时设置交换区. 1.使用分区: 在安装OS时划分出专门的交换分区,空间大小要事先规划好,启动系统时自动进行mount. 这种方法只能在安装OS时设定,一旦设定好不容易改变,除非重装系统. 2.使用swapfile:(或者是整个空闲分区) 新建临时swap

win7 64 下 VS2008 调试、退出时错误的解决

最近调试老程序的时候发现原来的VS2008会偶尔在调试C++程序的时候出现程序未响应的情况,开始还以为是个案,后来出现的频率越来越高完全影响心情啊!! 准备花时间解决一下这个问题.网上搜索没有发现任何有价值线索,于是决定用上绝招--安装盘修复,但结果依然是那样.准备用process monitor监测一下,发现信息太多基本不太可能一一人工分析. 在解决问题的时候还发现了一个问题.启动VS2008后,打开一个项目,不做任何修改点全部保存,然后关闭VS2008,此时VS2008会出现异常100%可重

ubuntu下apache虚拟主机出现forbidden错误的解决办法

交换两个变量:例如num1=5,num2=6→num1=6,num=5 怎么样?是不是觉得灰常简单,你是不是用下面的方法做的: int num1=5: int num2=6: int temp=num1: num1=num2; num2=temp; Console.WriteLine("num1={0},num2={1}",num1,num2); 好吧!你赢了!你做的非常对!就就是所谓的值传递 声明一个中间变量temp!没有可说的!大家都懂的! 接着我们来看下面这个比较犀利的出题人: