Linker errors in Android NDK (undefined reference to `__cxa_end_cleanup')
在 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.htmlI 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 := –frttiYou 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')的更多相关文章
- NDK undefined reference to 'rand'
NDK 编译 结果报错undefined reference to 'rand' 最怪异的是armeabi-v7a armeabi的情况下有问题 但是arm64-v8a编译正常,用网上说的添加头文件s ...
- Android APP使用NDK编译后的ffmpeg库出现undefined reference to 'posix_memalign'错误
在android程序中使用NDK编译后的ffmpeg库的时候出现了如下错误: jni/libs/libavutil.a(mem.o): in function av_malloc:libavutil/ ...
- Android NDK编译之undefined reference to 'JNI_CreateJavaVM'
利用Android NDK编译动态库,在C文件中调用了两个JNI函数:JNI_GetDefaultJavaVMInitArgs和JNI_CreateJavaVM.编译的时候始终报以下错误: XXX: ...
- 安卓ndk 忽略 error: undefined reference to '找不到符号
最近在搞天使之翼的mrp模拟器... 移到AndroidStudio了,现在想把原来的Android .mk那种方式的改成cmake的方式编译,但是编译时有一些符号找不到. undefined ref ...
- Android编译错误——undefined reference to
[错误描述] 未定义引用 提示如下:bootable/recovery/minzip/Zip.c:1122: error: undefined reference to 'selabel_lookup ...
- cocos2d-x android 添加新场景报错: undefined reference to `vtable for XXX'
转载自 居家懒人 http://www.cnblogs.com/JD85/archive/2012/09/17/2688128.html 加入写了新场景SecondScene,结果在cpp文件里类名地 ...
- Windows编译OpenCV4Android解决undefined reference to std错误
注意OpenCV 4.0.1 解决了这个问题请直接下载OpenCV 4.0.1 但是OpenCV 4.0.1作为模块导入Android Studio会有找不到R.styleable的问题 OpenCV ...
- Android NDK 学习之Android.mk
Android.mk file syntax specification Introduction: This document describes the syntax of Android.mk ...
- undefined reference to `__android_log_print'
使用android studio 编写NDK代码时出现错误:undefined reference to `__android_log_print' 解决办法: eclipse andro ...
随机推荐
- CCPC-Wannafly Winter Camp Day1部分题目解析
Preface 最近恰好不知道做什么题,所以就按老叶要求做上面的比赛. 稍微看了下感觉难度适中,大部分题目偏向联赛难度,当然也有些题目打到了省选题的感觉(基本都是Div1的题) 这里就简单拿一些我做得 ...
- 基于 HTML5 的 WebGL 3D 档案馆可视化管理系统
前言 档案管理系统是通过建立统一的标准以规范整个文件管理,包括规范各业务系统的文件管理的完整的档案资源信息共享服务平台,主要实现档案流水化采集功能.为企事业单位的档案现代化管理,提供完整的解决方案,档 ...
- C语言 课堂随记
1.codeblocks中的pow函数会有误差. 自定义pow函数: int pow(int x,int y) { ; ; i<=y; i++) t=t*x; return t; } 2.C库函 ...
- centos7之vsftp安装和使用
日常用作中,我们常用的是windows的共享,但是我们都知道windows运行不稳定.原来我们用的是centos6.5上的vsftpd,最近决定把centos6.*上的服务都移植到centos7上,好 ...
- 解决多线程安全问题-无非两个方法synchronized和lock 具体原理(百度-美团)
还有其他的锁,如果想要了解,参考:JAVA锁机制-可重入锁,可中断锁,公平锁,读写锁,自旋锁, 用synchronized实现ReentrantLock 美团面试题参考:使用synchronized ...
- 【XSY2903】B 莫比乌斯反演
题目描述 有一个\(n\times n\)的网格,除了左下角的格子外每个格子的中心里都有一个圆,每个圆的半径为\(R\),问你在左下角的格子的中心能看到多少个圆. \(n\leq {10}^9,R_0 ...
- poj 3764 The xor-longest Path (01 Trie)
链接:http://poj.org/problem?id=3764 题面: The xor-longest Path Time Limit: 2000MS Memory Limit: 65536K ...
- 安装 R 包报错 clang: error: unsupported option '-fopenmp' 的解决方法
MacOS 上安装 R 包 install.packages("data.table") 后面提示是否安装需要编译的版本: Do you want to install from ...
- mysql表加锁、全表加锁、查看加锁、解锁
单个表锁定: 格式: LOCK TABLES tbl_name {READ | WRITE},[ tbl_name {READ | WRITE},……] 例子: lock tables db_a.tb ...
- 深入理解JVM(5)——垃圾收集和内存分配策略
1.垃圾收集对象 垃圾收集主要是针对堆和方法区进行. 程序计数器.虚拟机栈和本地方法栈这三个区域属于线程私有的,只存在于线程的生命周期内,线程结束之后也会消失,因此不需要对这三个区域进行垃圾回收. 哪 ...