这个错误意味着什么以及如何解决它?
我正在尝试在 android 中使用 NDK 构建 C++ 代码。我有一个方法,它有一个参数 vector <;向量
一切都构建得很好,直到我在方法
vector
我开始收到此错误,
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 也没有提供帮助。
谢谢。
I am trying to build a C++ code using NDK in android. I have a method which has a parameter vector < vector <float> > coordinates
Everything builds fine until I write this line inside my method
vector<float> firstPoint = coordinates.at(0);
I start getting this error
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
I have no clue why this is happening and Google is not helping either.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我认为您在同一项目中使用标准库的两种不同实现。
看起来您正在使用 D:/android... 中标准库的 stlport 实现(的标头)来编译文件,并且链接到本地库。
您必须在 ide (或 Makefile)中配置链接器才能使用相同实现的 lib 文件(在 D:/android 中的某个位置...我猜)。
I think you are using two different implementation of the standard library in the same project.
It looks like you are compiling your files with (the headers of) an stlport implementation of the standard library in D:/android..., and you link against your local library.
You have to configure the linker in your ide (or Makefile) to use also the lib file of the same implementation (somewhere in D:/android... I guess).
这是一个链接错误。您需要将
APP_STL := stlport_static
添加到您的Apllication.mk
文件中。另请确保使用-fno-exceptions
标志,因为 STLport 与 C++ 异常和 RTTI 不兼容。您可以在
APPLICATION-MK.HTML
< 中获取更多信息/a> 可在 NDK 的docs
文件夹中找到。CPLUSPLUS-SUPPORT.HTML
也值得一读。This is a linking error. You need to add
APP_STL := stlport_static
to yourApllication.mk
file. Also make sure that you use-fno-exceptions
flag, since STLport is not compatible with C++ exceptions and RTTI.You can get more info in
APPLICATION-MK.HTML
which is availavle in thedocs
folder of the NDK.CPLUSPLUS-SUPPORT.HTML
is also worth to read.这看起来像是链接器错误。您可能忘记将 STL 库引用添加到您的构建中。或者找不到
this looks like a linker error. You probably forgot to add STL library reference to your build. Or it can't be found
你这样做了吗?
Did you do this ?
当我更改
为
它时,它开始编译......:sy?
When I changed
to
it started compiling..... :s y?