Reputation: 10037
I'm building a fat APK that contains separate *.so libs for armeabi
and armeabi-v7a
. I build using the command line only (i.e. using ndk-build
and ant
). Is there a way to detect from my C code whether the ndk-build
is currently building for armeabi
or for armeabi-v7a
? Preferably, I would like to be able to detect this at compile time, but if there is no other choice an architecture detection at runtime would also be sufficient.
E.g. is there something like
#ifdef __armeabiv7a__
...
#else
...
#endif
to detect the architecture at compile time?
I know that I can pass additional compiler flags in LOCAL_CFLAGS
in Android.mk
but these flags are always passed for all architectures so it doesn't help me. Or is there a tag that I could use in Android.mk
to pass specific flags for armeabi
or armeabi-v7a
only?
Upvotes: 1
Views: 827
Reputation: 13317
At least gcc provides quite a bit of predefined macros that one can check, to get info about the current ABI. For this case, you could check either this:
#if defined(__ARM_ARCH) && __ARM_ARCH >= 7
Or this:
#ifdef __ARM_ARCH_7A__
By manually setting these in the makefile as suggested by Michael you don't need to keep track of what different ABI macros there are, though, and have less risk of getting into unintended situations if moving to a compiler that doesn't have the same predefined macros (such as the MSVC compiler, although you won't be using that for Android).
Upvotes: 1
Reputation: 58427
I know that I can pass additional compiler flags in
LOCAL_CFLAGS
in Android.mk but these flags are always passed for all architectures
There's nothing preventing you from setting a flag only when building for a certain ABI:
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_CFLAGS += -DARMEABI_V7A
endif
Upvotes: 2