android - 这个错误意味着什么以及如何解决它?

标签 android c++ compiler-errors android-ndk android-stlport

我正在尝试在 android 中使用 NDK 构建 C++ 代码。我有一个方法有一个参数 vector < vector <float> > coordinates

一切都很好,直到我在我的方法中写下这一行

vector<float> firstPoint = coordinates.at(0);

我开始收到这个错误

D:/eclipseworkspace/myLibProject/obj/local/armeabi/libmyLibProject.a(FileName.o): In function `std::priv::_Vector_base<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > >::_M_throw_out_of_range() const':
D:/androidndk/sources/cxx-stl/stlport/stlport/stl/_vector.c:45: undefined reference to `std::__stl_throw_out_of_range(char const*)'
collect2: ld returned 1 exit status
make: *** [/cygdrive/d/eclipseworkspace/myLibProject/obj/local/armeabi/libOutputName.so] Error 1

我不知道为什么会这样,Google 也没有提供帮助。

谢谢。

最佳答案

我认为您在同一项目中使用标准库的两种不同实现。

看起来您正在使用 D:/android... 中标准库的 STLport 实现(的 header )编译您的文件,并且您链接到您的本地库。

您必须在您的 ide(或 Makefile)中配置链接器以使用相同实现的 lib 文件(我猜是在 D:/android 中的某处...)。

关于android - 这个错误意味着什么以及如何解决它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7185831/

相关文章:

c++ - 如何最好地使用抽象基类作为接口(interface)而不重复兄弟类函数重写

android - 在eclipse中如何创建一个新的cpp文件

c++ - 将 void* 转换回数组

assembly - 使用uVision ARM编译器的未知操作码 'CBZ'

c - GTK 应用程序使用 gcc 编译,但不在代码块中编译

android - 从服务器下载数据时设置进度条

java - notificationItemInserted Range() 不适用于 recyclerview 适配器

Android - 向范围内的所有手机信号塔发送回声请求

java - 使用 HttpUrlConnection 发送图像文件时出现 HTTP_BAD_REQUEST 错误

c# - 未分配的局部变量是否保证 CS0165 C# 编译器错误?