Android NDK 交叉编译C++代码生成.so共享库详细步骤

Android NDK 交叉编译C++代码生成.so共享库详细步骤

Android NDK 调用c++ stl 模板库(修改android.mk文件)

 

1  在需要调用模板库的文件前包含头文件:
 
   #include
  #include
 
  此时编译可能不过,需要在android.mk文件内添加:
  
LOCAL_C_INCLUDES :=   /home/administrator/android-ndk-r5b/sources/cxx-stl/stlport/stlport     (ndk安装路径下的stl库)
 
 
 2  在 mk 文件前加入:
 
   APP_STL  :=  stlprot_static    (模板库以静态库的方式添加)
 
  ....
  LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib  -llog \
 /home/administrator/android-ndk-r5b/sources/cxx-stl/stlport/libs/armeabi/libstlport_static.a
 
我的Android.mk文件中的内容为:
 
LOCAL_PATH := $(call my-dir)

LOCAL_C_INCLUDES += external/stlport/stlport
LOCAL_C_INCLUDES += bionic
LOCAL_C_INCLUDES += bionic/libstdc++/include

LOCAL_SHARED_LIBRARIES := libstlport

GXPM_LIB_DIR := ../../../common/GoxceedPM

include $(CLEAR_VARS)
	#$(GXPM_LIB_DIR)/minidb/minilzo/minilzo.c 	\

GXPM_SRC_FILES := \
	$(GXPM_LIB_DIR)/zlib/adler32.c      		\
	$(GXPM_LIB_DIR)/zlib/compress.c      		\
	$(GXPM_LIB_DIR)/zlib/crc32.c      		\
	$(GXPM_LIB_DIR)/zlib/deflate.c      		\
	$(GXPM_LIB_DIR)/zlib/gzio.c      		\
	$(GXPM_LIB_DIR)/zlib/inffast.c      		\
	$(GXPM_LIB_DIR)/zlib/inflate.c      		\
	$(GXPM_LIB_DIR)/zlib/inftrees.c      		\
	$(GXPM_LIB_DIR)/zlib/trees.c      		\
	$(GXPM_LIB_DIR)/zlib/uncompr.c      		\
	$(GXPM_LIB_DIR)/zlib/zutil.c      		\
	$(GXPM_LIB_DIR)/lz4/lz4.c      		\
	$(GXPM_LIB_DIR)/lz4/lz4frame.c      		\
	$(GXPM_LIB_DIR)/lz4/lz4hc.c      		\
	$(GXPM_LIB_DIR)/lz4/xxhash.c      		\
	$(GXPM_LIB_DIR)/minilzo/minilzo.c      		\
	$(GXPM_LIB_DIR)/minidb/bitmap.c      		\
	$(GXPM_LIB_DIR)/minidb/buddy.c       		\
	$(GXPM_LIB_DIR)/minidb/compressor.cpp		\
	$(GXPM_LIB_DIR)/minidb/compr_lz4.cpp 		\
	$(GXPM_LIB_DIR)/minidb/compr_lz77.cpp		\
	$(GXPM_LIB_DIR)/minidb/compr_lzo.cpp 		\
	$(GXPM_LIB_DIR)/minidb/compr_zlib.cpp		\
	$(GXPM_LIB_DIR)/minidb/db.cpp        		\
	$(GXPM_LIB_DIR)/minidb/hash.c        		\
	$(GXPM_LIB_DIR)/minidb/io.cpp        		\
	$(GXPM_LIB_DIR)/minidb/map.c         		\
	$(GXPM_LIB_DIR)/textcode_convert.c		\
	
LOCAL_SRC_FILES := \
	$(GXPM_SRC_FILES)		\
	gomedia.cpp

LOCAL_C_INCLUDES := \
	$(LOCAL_PATH)/../../../common/GoxceedPM/zlib/include 		\
	$(LOCAL_PATH)/../../../common/GoxceedPM/lz4 			\
	$(LOCAL_PATH)/../../../common/GoxceedPM/minilzo 		\
	$(LOCAL_PATH)/../../../common/GoxceedPM/minidb 			\
	$(LOCAL_PATH)/../../../common/GoxceedPM/core 		\
	$(LOCAL_PATH)/../../../common/GoxceedPM				\
	
LOCAL_LDLIBS := -llog
	
LOCAL_MODULE := gomedia
	
include $(BUILD_SHARED_LIBRARY)
	

Application.mk:

APP_ABI := all
APP_PLATFORM := android-8
APP_STL  :=  stlport_static
APP_CPPFLAGS := -fpermissive  

 

aa

 

你可能感兴趣的:(Android NDK 交叉编译C++代码生成.so共享库详细步骤)