安卓 JNI C++中的"Not declared in this scope"错误
"Not declared in this scope" error in Android JNI C++
我有这个使用C++的JNI代码。
#include <eigenfaces_jni.h>
#include <opencv2/core/core.hpp>
#include <opencv2/contrib/contrib.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
using namespace cv;
JNIEXPORT jstring JNICALL Java_com_example_facedetector_FaceTracker_nativeCreateObject
(JNIEnv *env, jclass, jstring JFileDir){
// These vectors hold the images and corresponding labels.
vector<Mat> images;
const char *str = env->GetStringUTFChars(jFileDir, NULL);
const char *buf;
/*Releasing the Java String once you have got the C string
is very important!!!*/
env->ReleaseStringUTFChars(jFileDir, str);
Mat im = imread(jFileDir);
if (im.empty())
{
cout << "Cannot load image!" << endl;
buf = "Can load image";
}
else{
buf = "Cannot load image";
}
return env->NewStringUTF("Hello");
}
但是,在
const char *str = env->GetStringUTFChars(jFileDir, NULL);
其中指出
- Symbol 'jFileDir' could not be resolved
- 'jFileDir' was not declared in this scope
- Invalid arguments ' Candidates are: const char * GetStringUTFChars(_jstring *, unsigned
char *) '
已尝试此链接中的解决方案 无法解析类型"std::string"。仍然不工作。任何解决此问题的帮助将不胜感激。谢谢。
您已经声明了一个名为 JFileDir
的函数参数,但没有声明名为 jFileDir
的函数参数。C++区分大小写。
好吧,由于我没有足够的声誉点来表扬,所以我必须写这个作为答案。检查你的函数参数列表(JNIEnv *env,jclass,jstring JFileDir(,jclass是关于什么的,我觉得这里缺少一些东西。
相关文章:
- 如何修复"error: ‘_1’ was not declared in this scope"?
- 类中的数组变量C++导致"was not declared in this scope"实现文件的一个函数中错误,但在构造函数中不会导致错误
- 如何解决"cout was not declared in this scope"错误?
- 为什么程序显示我"was not declared in this scope"?
- 为什么我会收到此警告? "Member 'x' was not initialized in this constructor"
- 即使包含 <time.h 后仍"‘CLOCK_PER_SEC’ was not declared in this scope"错误>
- С 错误"s1, s2 are used uninitialised in this function"
- "C4649: attributes are ignored in this context"的含义是什么?
- 我正在接受"Error: string was not declared in this scope"
- C++ 我一直在"was not declared in this scope error"
- 将 .ui 文件导入 Qt5 C++时出错"was not declared in this scope"
- 编译 CPP 应用程序时出错。 "error: 'posix_memalign' was not declared in this scope"
- main.cpp中的错误:函数库中的函数"not declared in this scope",但实际上是
- "Error: 'dungeon_t' was not declared in this scope"但包含在标题中
- "pointer was not declared in this scope"是什么意思
- "error: not declared in this scope?"是什么意思
- 宣布时的另一个'not declared in this scope'问题
- " 'X' not declared in this scope "错误
- 子类模板错误 (C++): "error: 'root' was not declared in this scope"
- Eclipse C++ Linux "to_string was not declared in this scope"