在Android NDK删除异常/放松功能的共享对象 [英] Remove exception/unwind functions from Android NDK shared objects
问题描述
不管我怎么努力,比如增加编译器标志 -fno-例外-fno-RTTI
,我总是在我的共享对象获取这些异常处理功能:
No matter what I try, like adding the compiler flags -fno-exceptions -fno-rtti
, I always get these exception-handling functions in my shared objects:
这发生了,我是否编译C或C ++。
This happens whether I compile as C or C++.
它发生这些包括(编译为C ++ - 没有试过编译为C):
It happens with these includes (compiled as C++ - haven't tried to compile as C):
#include <jni.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
下面是我所有的包括了一个我已经编译为C和C ++(大多数/所有的人都不需要要发生的问题):
Here are all of my includes for the one I have compiled as both C and C++ (most/all of them aren't needed for the problem to occur):
#include <jni.h>
#ifndef __cplusplus
#include <stdbool.h>
#endif
#include <math.h>
#ifdef __ANDROID__
#include <GLES2/gl2.h>
#else
#error "No graphics implementation for the target platform"
#endif
#ifdef __ANDROID__
#include <SLES/OpenSLES.h>
#include <SLES/OpenSLES_Android.h>
#include <pthread.h>
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
#else
#error "No audio implementation for the target platform"
#endif
#include <time.h>
typedef struct timespec timespec;
// for malloc, free and memset
#include <stdlib.h>
#include <string.h>
我怎样才能摆脱这些异常处理函数一劳永逸?是NDK工具链覆盖我的编译器标志的地方?
How can I get rid of these exception handling functions once and for all? Is the NDK toolchain overriding my compiler flags somewhere?
推荐答案
这是最有可能的,因为你链接到的静态C ++ STL。即使你的模块不使用异常,则补充交易通常做(NDK补充交易不具有 -fno-例外
变量)。
This is most likely because you are linking against a static C++ STL. Even if your module doesn't use exceptions, the STLs usually do (NDK STLs do not have an -fno-exceptions
variant).
这篇关于在Android NDK删除异常/放松功能的共享对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!