0

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?

fgsfdsfgts
  • 87
  • 2
  • 8
  • Are you linking other code in with yours? Have you examined your .o files to see what they reference? – fadden Feb 25 '16 at 17:15
  • I'm using jni.h as well as standard C library headers like math.h, stdint.h, stdlib.h and string.h, but not any other libraries. Could you tell me how to examine my .o files? – fgsfdsfgts Feb 25 '16 at 17:31

1 Answers1

0

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

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
  • Even though this may be an accurate answer, simply linking to another site is generally discouraged. To make this a complete answer, keep the link, but also summarize what the napkin in your picture is saying. If nothing else, this will keep the answer on the site even if the one you link to gets taken down someday. – David Mar 24 '16 at 22:24