【发布时间】:2014-01-18 15:11:43
【问题描述】:
作为 NDK 工作的一部分,我正在尝试将以下 C++ 代码移植到 Android:
#include <fstream>
// ...
inline void trim(string & str, const string & delim = " \t\r\n")
{
string::size_type pos = str.find_last_not_of(delim);
if(pos == string::npos) str.erase(str.begin(), str.end());
else
{
str.erase(pos+1);
pos = str.find_first_not_of(delim);
if(pos != string::npos) str.erase(0, pos);
}
}
我在str.erase(pos+1); 和str.erase(0, pos) 收到以下消息:
Invalid arguments '
Candidates are:
std::basic_string<char,std::char_traits<char>,std::allocator<char>> & erase(?, ?)
__gnu_cxx::__normal_iterator<char *,std::basic_string<char,std::char_traits<char>,std::allocator<char>>> erase(__gnu_cxx::__normal_iterator<char *,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>)
__gnu_cxx::__normal_iterator<char *,std::basic_string<char,std::char_traits<char>,std::allocator<char>>> erase(__gnu_cxx::__normal_iterator<char *,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>, __gnu_cxx::__normal_iterator<char *,std::basic_string<char,std::char_traits<char>,std::allocator<char>>>)
'
我尝试了here 的建议,但没有帮助。相反,现在我收到了#include <fstream> 的新消息:
Unresolved inclusion: <fstream>
我需要做什么来解决这个问题?谢谢。
更新:我正在尝试将这段代码添加到构建和运行良好的 Android 项目中的现有 C++ 代码中。当我应用上面链接的更改时,我不仅得到了 fstream 的unresolved inclusion,而且还得到了一堆其他错误。例如,对于现有代码的以下块:
#include <jni.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <vector>
我也收到Unresolved inclusion 错误。所以事情变得更糟了。
【问题讨论】:
标签: android c++ porting invalid-argument