问题
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