我无法编译下面的程序使用编译C文件jni.h
PPConverter.java:
public class PPConverter {
private native void convert(String s);
public static void main(String[] args){
new PPConverter().convert(args[0]);
}
static {
System.loadLibrary("converter");
}
}
converter.c:
#include <jni.h>
#include <stdio.h>
#include "PPConverter.h"
JNIEXPORT void JNICALL Java_PPConverter_convert (JNIEnv *, jobject, jstring){
printf(jstring);
return;
}
由于我的工作UNIX,我正在使用以下命令来编译converter.c文件:
cc -I/usr/lib/jvm/java-6-openjdk/include converter.c -o libconverter.so
,但我收到以下错误:
converter.c: In function âJava_PPConverter_convertâ:
converter.c:5: error: parameter name omitted
converter.c:5: error: parameter name omitted
converter.c:5: error: parameter name omitted
converter.c:6: error: expected expression before âjstringâ
我在做什么错?
您是否阅读过错误信息?他们完全告诉你缺少什么:方法签名中参数的名称。 – 2011-01-06 03:04:48