我的application.mk如下
APP_STL := c++_shared#gnustl_static#c++_static#
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char #-Wno-error=format-security
APP_LDFLAGS := -latomic
#APP_GNUSTL_FORCE_CPP_FEATURES := exceptions
ifeq ($(NDK_DEBUG),1)
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
APP_OPTIM := debug
else
APP_CPPFLAGS += -DNDEBUG
APP_OPTIM := release
endif
NDK_TOOLCHAIN_VERSION = 4.9
另外jni下的android.mk如下:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
(call import-add-path,(LOCAL_PATH)/…/…/cocos2d)
(call import-add-path,(LOCAL_PATH)/…/…/cocos2d/external)
(call import-add-path,(LOCAL_PATH)/…/…/cocos2d/cocos)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
define walk
(wildcard (1)) (foreach e, (wildcard (1)/*), (call walk, $(e)))
endef
ALLFILES = (call walk, (LOCAL_PATH)/…/…/Classes)
FILE_LIST := hellocpp/main.cpp
FILE_LIST += (filter %.cpp, (ALLFILES))
FILE_LIST += (filter %.c, (ALLFILES))
FILE_LIST += (filter %.hpp, (ALLFILES))
LOCAL_SRC_FILES := (FILE_LIST:(LOCAL_PATH)/=)
FILE_INCLUDES := (shell find (LOCAL_PATH)/…/…/Classes -type d)
#FILE_INCLUDES += (LOCAL_PATH)/../fmod/inc
LOCAL_C_INCLUDES := (LOCAL_PATH)/…/…/Classes
LOCAL_C_INCLUDES += $(LOCAL_PATH)/…/fmod/inc
_COCOS_HEADER_ANDROID_BEGIN
_COCOS_HEADER_ANDROID_END
_COCOS_LIB_ANDROID_BEGIN
_COCOS_LIB_ANDROID_END
include $(LOCAL_PATH)/prebuilt/Android.mk
#LOCAL_SHARED_LIBRARIES := fmodL
LOCAL_STATIC_LIBRARIES := cocos2dx_static
include $(BUILD_SHARED_LIBRARY)
$(call import-module,.)
_COCOS_LIB_IMPORT_ANDROID_BEGIN
_COCOS_LIB_IMPORT_ANDROID_END
由于要使用一些C++11的特性原来的gnustl_static和c++_static无法编译通过最后用c++_shared 就可以
我不知道是不是这个原因,最后生成的so如下
上面的fmod是要使用的第三方库,而且这个第三方库的大小本来为1.38M在obj文件夹下生成的大小为37.8M最后在libs文件下却是3.92M非常诡异
我对比了默认的工程发现缺少了libcocos2dcpp.so的库,并且当项目拷贝so过去的时候居然拷贝的是libc++_shared.so,表示对ndk的编译非常不懂
,有高手帮忙看一下吗