Android 中移植一个库(该库 使用了 libstlport )时 产生如下错误:

./obj/local/armeabi/objs/jniWrapper/native.o: In function `_Vector_base':
D:/opt/android-ndk/sources/cxx-stl/stlport/stlport/stl/_vector.h:73: undefined reference to `__cxa_end_cleanup'
./obj/local/armeabi/objs/jniWrapper/native.o:(.ARM.extab.text._ZNSt6vectorIhSaIhEEC1ERKS1_[std::vector<unsigned char, std::allocator<unsigned char> >::vector(std::vector<unsigned char, std::allocator<unsigned char> > const&)]+0x0): undefined reference to `__gxx_personality_v0'
./obj/local/armeabi/objs/jniWrapper/native.o: In function `std::__node_alloc::deallocate(void*, unsigned int)':
D:/opt/android-ndk/sources/cxx-stl/stlport/stlport/stl/_alloc.h:161: undefined reference to `__cxa_end_cleanup'
./obj/local/armeabi/objs/jniWrapper/native.o:(.ARM.extab.text._ZNSt4priv12_String_baseIcSaIcEED2Ev[std::priv::_String_base<char, std::allocator<char> >::~_String_base()]+0x0): undefined reference to `__gxx_personality_v0'
./obj/local/armeabi/objs/jniWrapper/native.o: In function `basic_string':
D:/opt/android-ndk/sources/cxx-stl/stlport/stlport/stl/_string.c:643: undefined reference to `__cxa_end_cleanup'
  • After reading android-ndk/docs/CPLUSPLUS-SUPPORT.html I found that there a couple more libraries that I can link to:

                 C++       C++   Standard
    Exceptions RTTI Library system no no no
    gabi++ no yes no
    stlport no yes yes
    gnustl yes yes yes

    This stops my linker errors (and pushes the build onto a new set of errors :))

    Application.mk

    APP_STL := gnustl_static
  • Take a look here: Linux C++: Linker is outputting strange errors.

    In Android's Application.mk this would be:

    APP_CPPFLAGS := –frtti
  • You can fix this problem by adding the compiler option -lsupc++.

    Edited: The reason: your code is using C++ exception mechanism which compiler automatically generate try/catch/finally block hidden code which in turn call __cxa_end_cleanup somewhere. lsupc++ means link to libsupc++.a

    Another way to resolve this problem is add -fno-exceptions option to gcc which obviously means disable exception handler mechanism.

    BTW, you should also add -fno-rtti to avoid other maybe-encountered compilation error, this is because all android's C++ class is compiled without dynamic type info in class memory layout.

    In a word, you shoud use one of these option combos: 1. -fno-rtti -fno-exceptions 2. -fno-rtti -lsupc++

参考链接:http://quabr.com/9226513/linker-errors-in-android-ndk-undefined-reference-to-cxa-end-cleanup

Linker errors in Android NDK (undefined reference to `__cxa_end_cleanup')的更多相关文章

  1. NDK undefined reference to 'rand'

    NDK 编译 结果报错undefined reference to 'rand' 最怪异的是armeabi-v7a armeabi的情况下有问题 但是arm64-v8a编译正常,用网上说的添加头文件s ...

  2. Android APP使用NDK编译后的ffmpeg库出现undefined reference to 'posix_memalign'错误

    在android程序中使用NDK编译后的ffmpeg库的时候出现了如下错误: jni/libs/libavutil.a(mem.o): in function av_malloc:libavutil/ ...

  3. Android NDK编译之undefined reference to 'JNI_CreateJavaVM'

    利用Android NDK编译动态库,在C文件中调用了两个JNI函数:JNI_GetDefaultJavaVMInitArgs和JNI_CreateJavaVM.编译的时候始终报以下错误: XXX: ...

  4. 安卓ndk 忽略 error: undefined reference to '找不到符号

    最近在搞天使之翼的mrp模拟器... 移到AndroidStudio了,现在想把原来的Android .mk那种方式的改成cmake的方式编译,但是编译时有一些符号找不到. undefined ref ...

  5. Android编译错误——undefined reference to

    [错误描述] 未定义引用 提示如下:bootable/recovery/minzip/Zip.c:1122: error: undefined reference to 'selabel_lookup ...

  6. cocos2d-x android 添加新场景报错: undefined reference to `vtable for XXX'

    转载自 居家懒人 http://www.cnblogs.com/JD85/archive/2012/09/17/2688128.html 加入写了新场景SecondScene,结果在cpp文件里类名地 ...

  7. Windows编译OpenCV4Android解决undefined reference to std错误

    注意OpenCV 4.0.1 解决了这个问题请直接下载OpenCV 4.0.1 但是OpenCV 4.0.1作为模块导入Android Studio会有找不到R.styleable的问题 OpenCV ...

  8. Android NDK 学习之Android.mk

    Android.mk file syntax specification Introduction: This document describes the syntax of Android.mk  ...

  9. undefined reference to `__android_log_print'

    使用android studio 编写NDK代码时出现错误:undefined reference to `__android_log_print' 解决办法: eclipse       andro ...

随机推荐

  1. 关于mysql中unique的插入Duplicate key

    MySQL数据库中 如果在后台中不做判断是否unique的column是否存在的话,直接把数据操作给dao层再传给DB的话,就会报重复的唯一值.如果确实是不希望先取出判断unique的column是否 ...

  2. 【翻译】IdentityServer4:基于资源的配置

    这篇文章基于https://leastprivilege.com/2016/12/01/new-in-identityserver4-resource-based-configuration/进行翻译 ...

  3. MySQL系列:数据库基本操作(1)

    1. 登录数据库 mysql -h localhost -u root -p 2. 数据库基本操作 2.1 查看数据库 mysql> SHOW DATABASES; +------------- ...

  4. PS中如何提高修改psd图片的效率(自动选择工具)

    在photoshop中制作图片的时候,一般要养成保留psd格式的习惯,纵然普通时候jpg,png格式常用,考虑到以后可能需要修改,也应该备份一下.如果考虑到以后需要修改,可每次成品保存成两个,一个ps ...

  5. Python学习之路——迭代器

    迭代器 # 通过迭代器取值优缺点: # 优点:不依赖索引,完成取值 # 缺点:不能计算长度,不能指定位取值(只能从前往后逐一取值) 可迭代对象 ''' 可迭代对象: 有__iter__()方法的对象, ...

  6. Docker 删除容器日志

    在使用docker的时候,我们经常通过 docker logs -f containername或者id 但是有时候日志很多.很麻烦.所以需要清理一下对应container的日志. 默认情况下,dao ...

  7. 【转】Esp8266学习之旅① 搭建开发环境,开始一个“hellow world”串口打印。

    @2019-02-28 [小记] Esp8266学习之旅① 搭建开发环境,开始一个“hellow world”串口打印.

  8. <Android基础> (四) Fragment Part 2

    4.3 Fragment的生命周期 4.3.1 Fragment的状态和回调 1.运行状态 当一个Fragment是可见的,并且它关联的活动正处于运行状态是,该Fragment也处于运行状态 2.暂停 ...

  9. 20165223 《信息安全系统设计基础》 实现mybash

    一.了解 mybash 1. 简介   bash 是 Bourne Again Shell 的缩写,是linux默认的标准shell(也是大家常说的系统内核),bash也是Unix/Linux上常见的 ...

  10. 给react-native添加图标和启动屏

    react native 项目默认是没有图标,并且启动页面只有文字.这个样子并不能算是一个完整的APP,现在就给APP加一个图标和一个适应所有屏幕尺寸的启动图,并且设置启动图遮住项目启动时候的白色闪屏 ...