Thanks in advance. I have a Android ndk c++ file name native-lib.cpp just like
extern "C"
JNIEXPORT jstring
JNICALL
Java_foo_foo_foo_foo_HomeActivity_temp( JNIEnv *env, jobject ){
std::string password = getTempString();
return env->NewStringUTF( password.c_str() );
}
std::string getTempString(){
return "temp_string";
}
But it shows error on calling getTempString() that undeclared function getTempString(); Please help.
You need a declaration of getTempString
before the first use. One way is to use a prototype
// prototype
std::string getTempString();
extern "C"
JNIEXPORT jstring
JNICALL
Java_foo_foo_foo_foo_HomeActivity_temp( JNIEnv *env, jobject ){
std::string password = getTempString();
return env->NewStringUTF( password.c_str() );
}
std::string getTempString(){
return "temp_string";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.