Is there a preprocessor macro that will let me know NDK is compiling my code? I could manually define my own, but I'd rather not if possible.
The NDK itself invokes a customized cross-compiler built on the arm-eabi-gcc compiler.
With a project open, click Tools > SDK Manager. Click the SDK Tools tab. Select the NDK (Side by side) and CMake checkboxes. Note: If you have an NDK installed in the ndk-bundle folder, it appears in the list with the label NDK.
Overview. The Android.mk file resides in a subdirectory of your project's jni/ directory, and describes your sources and shared libraries to the build system. It is really a tiny GNU makefile fragment that the build system parses once or more.
The Native Development Kit (NDK) is a set of tools that allows you to use C and C++ code with Android, and provides platform libraries you can use to manage native activities and access physical device components, such as sensors and touch input.
It is #ifdef __ANDROID__
as seen by running the preprocessor:
~$ /usr/local/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc -E -dM - < /dev/null | grep -i android
The output is:
#define __ANDROID__ 1
No need to depend on defining stuff in your project especially if you're skipping the NDK build system.
Short answer: #ifdef ANDROID
.
The ANDROID
macro is defined for you in build-module.mk (part of the standard build system):
# always define ANDROID when building binaries # LOCAL_CFLAGS := -DANDROID $(LOCAL_CFLAGS)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With