Skip to content

Instantly share code, notes, and snippets.

@sh1r0

sh1r0/Android.mk Secret

Created May 29, 2016 07:32
Show Gist options
  • Save sh1r0/0ee4b83addf06157f3f5bcfc9294a082 to your computer and use it in GitHub Desktop.
Save sh1r0/0ee4b83addf06157f3f5bcfc9294a082 to your computer and use it in GitHub Desktop.
A sample ndk project setup based on caffe-android-lib

The sample project structure is shown below.

.
├── android_lib
├── jni
│   ├── Android.mk
│   ├── Application.mk
│   ├── caffe_jni.cpp
│   ├── caffe_mobile.cpp
│   └── caffe_mobile.hpp
└── prebuilt
    ├── arm64-v8a
    ├── armeabi
    ├── armeabi-v7a
    ├── x86
    └── x86_64
LOCAL_PATH := $(call my-dir)
# C++ full library
# =======================================================
include $(CLEAR_VARS)
LOCAL_MODULE := caffe
LOCAL_SRC_FILES := $(LOCAL_PATH)/../prebuilt/$(TARGET_ARCH_ABI)/libcaffe.so
include $(PREBUILT_SHARED_LIBRARY)
#-----------------------------------------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := caffe_jni
LOCAL_SRC_FILES := caffe_jni.cpp caffe_mobile.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../android_lib/caffe/include \
$(LOCAL_PATH)/../android_lib/boost/include \
$(LOCAL_PATH)/../android_lib/gflags/include \
$(LOCAL_PATH)/../android_lib/glog/include \
$(LOCAL_PATH)/../android_lib/protobuf/include \
$(LOCAL_PATH)/../android_lib/openblas/include \
$(LOCAL_PATH)/../android_lib/opencv/sdk/native/jni/include
#LOCAL_STATIC_LIBRARIES := openblas
LOCAL_SHARED_LIBRARIES := caffe
LOCAL_LDLIBS := -lm -llog
LOCAL_CPPFLAGS += -fexceptions -frtti -std=c++11 -DCPU_ONLY
# LOCAL_ARM_MODE := arm
include $(BUILD_SHARED_LIBRARY)
# include $(BUILD_EXECUTABLE)
NDK_TOOLCHAIN_VERSION := 4.9
APP_PLATFORM := android-21
APP_STL := gnustl_static
APP_ABI := armeabi armeabi-v7a x86 arm64-v8a x86_64
APP_MODULE := libcaffe_jni
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment