Windowsコマンドndk-buildコンパイル.soファイル

3142 ワード

1.NDKパッケージをダウンロードし、ndk-buildが存在するディレクトリを環境変数に設定します.
2.ソースディレクトリにjniディレクトリを新規作成します(Android.mkを何回か試しましたが、jniディレクトリにない場合はフルパスを書く必要があります).
3. Application.mk
#APP_ABI := all
#APP_ABI := arm64-v8a armeabi-v7a armeabi x86 x86_64
APP_ABI := arm64-v8a armeabi-v7a
APP_PLATFORM := android-14
#APP_STL := stlport_shared
APP_STL := stlport_static
APP_MODULES := Common

4. Android.mk
LOCAL_PATH := $(call my-dir)


######################################################### sqlite3 #########################################################


include $(CLEAR_VARS)

LOCAL_MODULE := sqlite3

MY_INCLUDES := -I$(LOCAL_PATH)/../..

LOCAL_SRC_FILES := ../../Framework/Sqlite3/sqlite3.c

LOCAL_CFLAGS := -DPlatform_Linux $(MY_INCLUDES) -Wall -O3

LOCAL_EXPORT_C_INCLUDES :=
LOCAL_EXPORT_CFLAGS :=
LOCAL_EXPORT_LDLIBS := -llog
include $(BUILD_STATIC_LIBRARY)


######################################################### cJSON #########################################################


include $(CLEAR_VARS)

LOCAL_MODULE := cJSON

MY_INCLUDES := -I$(LOCAL_PATH)/../..

LOCAL_SRC_FILES := ../../Framework/Json/cJSON.c

LOCAL_CFLAGS := -DPlatform_Linux $(MY_INCLUDES) -ldl -Wall -O3

LOCAL_EXPORT_C_INCLUDES :=
LOCAL_EXPORT_CFLAGS :=
LOCAL_EXPORT_LDLIBS := -llog
include $(BUILD_STATIC_LIBRARY)


######################################################### Common #########################################################


include $(CLEAR_VARS)

LOCAL_MODULE := Common


MY_INCLUDES := -I$(LOCAL_PATH)/../.. \
			-I$(LOCAL_PATH)/../../Framework/Interface/HAL \
			-I$(LOCAL_PATH)/../Common_IAR_820

MY_SRC_FILES := $(wildcard $(LOCAL_PATH)/../Code/*.cpp) \
					$(wildcard $(LOCAL_PATH)/../../Framework/express/*.cpp) \
					$(wildcard $(LOCAL_PATH)/../../Framework/Util/*.cpp) \
					$(wildcard $(LOCAL_PATH)/../../Framework/fs/*.cpp) \
					$(LOCAL_PATH)/../../HAL/linkLayer/Frame.cpp

LOCAL_SRC_FILES := $(MY_SRC_FILES)

#LOCAL_SRC_FILES := ../Code/BinStream.cpp \
#					../Code/ColumnData.cpp \
#					../Code/Common.cpp \
#					../Code/DataGetter.cpp \
#					../Code/ItemNode.cpp \
#					../Code/MenuTreeNode.cpp \
#					../Code/PublicText.cpp \
#					../Code/Resources.cpp \
#					../Code/Section.cpp \
#					../../Framework/express/FX_Math.cpp \
#					../../Framework/express/FX_Express.cpp \
#					../../Framework/Util/StringUtil.cpp \
#					../../Framework/fs/FxFile.cpp
#					$(LOCAL_PATH)/../../HAL/linkLayer/Frame.cpp
					

LOCAL_CFLAGS := -DPlatform_Linux $(MY_INCLUDES) -ldl -Wall -O3 -std=c++11

#      
LOCAL_STATIC_LIBRARIES := sqlite3 cJSON

#      
#LOCAL_SHARED_LIBRARIES :=

LOCAL_EXPORT_C_INCLUDES :=
LOCAL_EXPORT_CFLAGS :=
LOCAL_EXPORT_LDLIBS := -llog
#include $(BUILD_SHARED_LIBRARY)
include $(BUILD_STATIC_LIBRARY)

5.バッチの使用(便宜上)
@echo off

chcp 936


rem -jn :        CPU    
rem V=1:       
rem -B :       
rem NDK_LIBS_OUT=.so    
rem NDK_OUT=.a    
ndk-build -j4 -B V=1 NDK_DEBUG=1 NDK_LIBS_OUT=../../Libs/Debug/Android/libs NDK_OUT=../../Libs/Debug/Android/obj

pause

NDK_LIBS_OUT:生成されたダイナミックライブラリが存在するディレクトリ
NDK_OUT:生成する.oファイルがあるディレクトリ