android - JNI中写原生c++代码编译,各种 error: 'xxx' does not name a type?

查看:435
本文介绍了android - JNI中写原生c++代码编译,各种 error: 'xxx' does not name a type?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

本人小白,以前是做Android的,现在刚开始做ndk开发,就我一人,使用的是studio,现在一般的java和c++之间的调用和传参没什么问题,但是现在在做的是一个人脸识别的项目,公司使用的是c++写的代码,c++代码很多,然后使用让我使用jni进行调用里面的方法,但是面临一个头疼的问题,就是,写好头文件之后,现在在拷贝他们的c++代码进来,除了调用的几个函数实现的时候用的是JNI的方式,其他的函数都是用的原生的c++代码,结果报了很多错误,先是头文件的错误,include<io.h>,<windows.h>都不行,后来和老大协商一下,改了一些代码,头文件不报错了,但是现在定义的全局变量,在编译的时候报了很多很多类似error: 'map' does not name a type,error: 'vector' does not name a type的错误,还有很多error: 'cout' was not declared in this scope的这种错误,由于对c++不熟悉,所以现在特别头疼,希望各位大神指点一二,江湖救急啊!!
都是报的是原生C++中的错误

我已经在全局进行声明了

map<int, string> g_id2name;                                
map<int, int> g_id2line;                                
int g_numKeypoints = 0;                                    
int g_numObjects = 0;                                    
CvMemStorage* g_storageObj;                                
vector<int> g_labels;                                    
vector<int> g_laplacians;                                
CvSeq *g_dbKeypoints = 0;                                
CvMat* g_objMat;                                        
int g_curObject = 0;                                    
int g_matchFileStatus = 0;                                
char* g_matchFileName = 0;

还是报了很多下面这种错误

Error:(48, 1) error: 'map' does not name a type
Error:(53, 1) error: 'vector' does not name a type
Error:(94, 5) error: 'ifstream' was not declared in this scope
Error:(131, 9) error: 'cerr' was not declared in this scope
Error:(158, 5) error: 'cout' was not declared in this scope
Error:(160, 25) error: invalid operands of types 'int' and 'const char [2]' to binary 'operator<<'
Error:(536, 46) error: 'g_id2name' was not declared in this scope
    。。。。。。
    

解决方案

#include <map>
#include <vector>
//etc
using namespace std;

这篇关于android - JNI中写原生c++代码编译,各种 error: &#039;xxx&#039; does not name a type?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆