Cocos2d-x--避免手动在Android.mk文件中手动添加cpp文件

将Android.mk的内容替换成以下内容即可

LOCAL_PATH := $(call my-dir) 
 
include $(CLEAR_VARS) 
 
LOCAL_MODULE := hellocpp_shared 
 
LOCAL_MODULE_FILENAME := libhellocpp 
                    
FILE_LIST := hellocpp/main.cpp 
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp) 
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%) 
 
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes 

LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static
LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static

include $(BUILD_SHARED_LIBRARY)

$(call import-module,cocos2dx)
$(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl)
$(call import-module,CocosDenshion/android)
$(call import-module,extensions)
$(call import-module,external/Box2D)
$(call import-module,external/chipmunk)

其中LOCAL_MODULE_FILENAME := libhellocpp可以修改,

其是生成的库文件的名字,代码中用到的地方是

static {
        System.loadLibrary("hellocpp");
    } 


你可能感兴趣的:(编译,cocos2d-x,android.mk,手动添加cpp文件)