Remove exception/unwind functions from Android NDK shared objects

丶灬走出姿态 提交于 2019-12-23 04:52:24

问题


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:

Image

This happens whether I compile as C or 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>

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>

How can I get rid of these exception handling functions once and for all? Is the NDK toolchain overriding my compiler flags somewhere?


回答1:


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).



来源:https://stackoverflow.com/questions/35632959/remove-exception-unwind-functions-from-android-ndk-shared-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!