[英]“Invalid arguments” when porting C++ code to Android
I am trying to port the following piece of C++ code to Android as part of some NDK work: 我正在尝试将以下C ++代码片段移植到Android,作为某些NDK工作的一部分:
#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);
}
}
What I get is the following message at str.erase(pos+1);
我得到的是
str.erase(pos+1);
的以下消息str.erase(pos+1);
and str.erase(0, pos)
: 和
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>>>)
'
I tried what was suggested here but it did not help. 我尝试了这里提出的建议,但没有帮助。 Instead, now I am getting a new message for
#include <fstream>
: 相反,现在我收到一条有关
#include <fstream>
新消息:
Unresolved inclusion: <fstream>
What do I need to do to resolve this? 我需要怎么做才能解决这个问题? Thank you.
谢谢。
UPDATE: I am trying to add this piece of code to an existing C++ code in an Android project that built and ran fine. 更新:我正在尝试将这段代码添加到构建并运行良好的Android项目中的现有C ++代码中。 When I applied the change linked to above, I not only got the
unresolved inclusion
for fstream, I also got a bunch of other errors. 当我应用上面链接的更改时,不仅得到了fstream的
unresolved inclusion
,而且还出现了许多其他错误。 For instance, for the following block form the existing code: 例如,对于以下块形式的现有代码:
#include <jni.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <vector>
I am also getting Unresolved inclusion
errors. 我也收到
Unresolved inclusion
错误。 So it made things worse. 因此,情况变得更糟。
尝试将以下行添加到您的项目的Application.mk
。
APP_STL := gnustl_static
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.