编译时报错啊:gcc -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -fPIC -c Hello.c cat Hello.c [code]#include "Hello.h" #include <stdio.h>//与Hello.h中函数声明相同 JNIEXPORT void JNICALL Java_Hello_SayHello(JNIEnv * env, jobject arg, jstring instring) { //从instring字符串取得指向字符串UTF编码的指针 const jbyte *str = (const jbyte *)env->GetStringUTFChars(instring, JNI_FALSE); printf("Hello, %s\n",str); //通知虚拟机本地代码不再需要通过str访问Java字符串。 env->ReleaseStringUTFChars(instring, (const char *)str); return; }[/code]ello.c: In function `Java_Hello_SayHello': Hello.c:8: request for member `GetStringUTFChars' in something not a structure or union Hello.c:13: request for member `ReleaseStringUTFChars' in something not a structure or union 我是按网上的例子来的,为什么别人可以,我的不行?
cat Hello.c
[code]#include "Hello.h"
#include <stdio.h>//与Hello.h中函数声明相同
JNIEXPORT void JNICALL Java_Hello_SayHello(JNIEnv * env, jobject arg, jstring instring)
{
//从instring字符串取得指向字符串UTF编码的指针
const jbyte *str = (const jbyte *)env->GetStringUTFChars(instring, JNI_FALSE); printf("Hello, %s\n",str); //通知虚拟机本地代码不再需要通过str访问Java字符串。
env->ReleaseStringUTFChars(instring, (const char *)str); return;
}[/code]ello.c: In function `Java_Hello_SayHello':
Hello.c:8: request for member `GetStringUTFChars' in something not a structure or union
Hello.c:13: request for member `ReleaseStringUTFChars' in something not a structure or union
我是按网上的例子来的,为什么别人可以,我的不行?
.:/home/jstudy/src/jni:/home/jstudy/lib:/home/sybase/OCS-12_5/lib:路径应该是对的亚。我用的是System.loadLibrary("hello");
看看这个