当前位置: 技术问答>linux和unix
编译JNI.h报大量错
来源: 互联网 发布时间:2016-07-12
本文导语: 大家好,我想用jni给我的C++包壳,以便他用JAVA程序调用 我编译的时候发现jni.h报出了大量的错误 我用gcc -c jni.h 返回: In file included from jni.h:27: jni_md.h:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__at...
大家好,我想用jni给我的C++包壳,以便他用JAVA程序调用
我编译的时候发现jni.h报出了大量的错误
我用gcc -c jni.h 返回:
In file included from jni.h:27:
jni_md.h:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘jlong’
jni.h:108: error: expected specifier-qualifier-list before ‘jlong’
jni.h:202: error: expected ‘)’ before ‘*’ token
jni.h:204: error: expected ‘;’ before ‘jclass’
jni.h:1877: error: expected ‘)’ before ‘*’ token
jni.h:1879: error: expected ‘;’ before ‘jint’
jni.h: In function ‘__declspec’:
jni.h:1917: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘JNI_GetDefaultJavaVMInitArgs’
jni.h:1919: error: expected declaration specifiers before ‘__declspec’
jni.h:1922: error: expected declaration specifiers before ‘__declspec’
jni.h:1926: error: expected declaration specifiers before ‘__declspec’
jni.h:1929: error: expected declaration specifiers before ‘__declspec’
jni.h:1930: error: expected ‘{’ at end of input
-----------------------
如果我要是用g++ 编译,返回的错误更多?请问这是为什么
我编译的时候发现jni.h报出了大量的错误
我用gcc -c jni.h 返回:
In file included from jni.h:27:
jni_md.h:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘jlong’
jni.h:108: error: expected specifier-qualifier-list before ‘jlong’
jni.h:202: error: expected ‘)’ before ‘*’ token
jni.h:204: error: expected ‘;’ before ‘jclass’
jni.h:1877: error: expected ‘)’ before ‘*’ token
jni.h:1879: error: expected ‘;’ before ‘jint’
jni.h: In function ‘__declspec’:
jni.h:1917: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘JNI_GetDefaultJavaVMInitArgs’
jni.h:1919: error: expected declaration specifiers before ‘__declspec’
jni.h:1922: error: expected declaration specifiers before ‘__declspec’
jni.h:1926: error: expected declaration specifiers before ‘__declspec’
jni.h:1929: error: expected declaration specifiers before ‘__declspec’
jni.h:1930: error: expected ‘{’ at end of input
-----------------------
如果我要是用g++ 编译,返回的错误更多?请问这是为什么
|
应该使用-I把jni的路径加入gcc的头文件搜索路径。
不过你怎么直接编译起头文件来了?
不过你怎么直接编译起头文件来了?
|
缺少很多头文件的, 用-I加上头文件路径。
|
jni.h肯定包含了其他系统头文件或者自定义文件你没有包含。