从Android NDK共享对象中删除exception / unwind函数 [英] Remove exception/unwind functions from Android NDK shared objects

查看:256
本文介绍了从Android NDK共享对象中删除exception / unwind函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论我尝试什么,例如添加编译器标志 -fno-exceptions -fno-rtti ,我总是在我的共享对象中获取这些异常处理函数: / p>

图片



无论是以C或C ++编译,都会发生这种情况。



编译为C):

  #include< jni.h> 
#include< math.h>
#include< stdint.h>
#include< stdlib.h>
#include< string.h>

这里是我编译为C和C ++的问题不需要发生):

  #include< jni.h> 

#ifndef __cplusplus
#include< stdbool.h>
#endif

#include< math.h>

#ifdef __ANDROID__
#include< GLES2 / gl2.h>
#else
#error没有针对目标平台的图形实现
#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目标平台没有音频实现
#endif

#include< time.h>
typedef struct timespec timespec;

//用于malloc,free和memset
#include< stdlib.h>
#include< string.h>

如何彻底摆脱这些异常处理函数?是否NDK工具链覆盖我的编译器标志的某个地方?

解决方案

这很可能是因为你链接到静态C ++ STL。即使你的模块不使用异常,STL通常也做(NDK STL没有 -fno-exceptions 变体)。


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?

解决方案

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共享对象中删除exception / unwind函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆