![]() It is also possible to write pure C and C++ native. Lets use standard hello world as an application that we want to run on. Android NDK and CMake A physical test device with debugging enabled or the Android Emulator with Android 5.0 or higher. Note that the C and C++ Android App examples use a Java wrapper class with JNI. I started with the default Hello world application ( C++ option selected). This page discusses how to use CMake with the NDK via the Android Gradle. Anyways, here below I present 2 methods of compiling C programs with Android NDK. 2 Im using Android Studio 2.2.3 with OpenCV SDK. 1 # Change this to whereever you keep NDKĥ DBG ?= 0 6 7 # Debug/Release configurationĨ ifeq ( $( DBG ) ,1) 9 MODE_FLAGS = -DDEBUG -g -O0ġ0 else 11 MODE_FLAGS = -Os -fdata-sections -ffunction-sectionsġ2 endif 13 14 # NDK configuration (clang)ġ7 NDK_TARGETVER = 27 18 19 # Target arch - here aarch64 for androidĢ0 NDK_TARGETARCH = aarch64-linux-androidĢ7 28 # Architecture of a machine that does cross compilationģ2 NDK_TOOLS = $(NDK )/toolchains/llvm/prebuilt/ $(NDK_HOSTARCH )/binģ5 NDK_LIBS = $(NDK )/toolchains/ $(NDK_TARGETARCH )- $(NDK_TOOLVER )/prebuilt/linux-x86_64/lib/gcc/ $(NDK_TARGETARCH )/4.9.xģ6 NDK_INCLUDES = -I $(NDK )/sysroot/usr/include \ģ7 -I $(NDK )/sysroot/usr/include/ $(NDK_TARGETARCH ) 38 NDK_SYSROOT = $(NDK )/platforms/android- $(NDK_TARGETVER )/arch- $(NDK_TARGETSHORTARCH ) 39 40 # Options common to compiler and linkerĤ5 -target $(NDK_TARGETARCH ) 46 47 # Compiler optionsĤ9 $(NDK_INCLUDES ) 50 51 # Linker optionsĥ6 -B $(ANDROID_NDK )/toolchains/ $(NDK_TARGETARCH )- $(NDK_TOOLVER )/prebuilt/linux-x86_64/ $(NDK_TARGETARCH )/bin \ĥ7 -L $(NDK_LIBS ) 58 59 all : 60 $(NDK_TOOL ) -c $(SRCDIR )/main.c -o $(OBJDIR )/main.o $(CFLAGS ) 61 $(NDK_TOOL ) -o main $(OBJDIR )/main.o $(LDFLAGS ) 62 63 adb-prepare : 64 adb rootĬopy this file to same directory as main. cmakegeneratorNinja I have confirmed that.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |