cocos2dx 3.3final 编译Android 平台
因为前段时间都在用quick,所以对C++这边又感觉陌生。最近在写项目,用C++的,编译的时候遇见蛋疼的问题,也怪我缺乏经验。。。
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cocos2dcpp_shared LOCAL_MODULE_FILENAME := libcocos2dcpp #遍历目录及子目录的函数 define walk $(wildcard $(1)) $(foreach e, $(wildcard $(1)/*), $(call walk, $(e))) endef # 遍历Classes目录 ALLFILES = $(call walk, $(LOCAL_PATH)/../../Classes) FILE_LIST := hellocpp/main.cpp # 从所有文件中提取出所有.cpp文件 FILE_LIST += $(filter %.cpp, $(ALLFILES)) 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 += cocos_extension_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_network_static include $(BUILD_SHARED_LIBRARY) $(call import-module,2d) $(call import-module,audio/android) $(call import-module,Box2D) $(call import-module,network) $(call import-module,extensions)
这是以前项目的android.mk文件,我直接拷贝过来用。。。编译的时候发现如下错误
然后直接乱写,把以上$(call import-module,2d)类似的代码都删除,就保留一个$(call import-module,.),试着编译,竟然成功了!!!!!!好开心。。。
但在导入到eclipse的时候,报错看不懂。。。。
最终发现原来是版本问题,我拷贝的android.mk是3.0的。。。。我现在开发是3.3.。。两者的区别是$(call import-module,2d)改成了$(call import-module,.),其他不变,但是LOCAL_WHOLE_STATIC_LIBRARIES增加了什么,$(call import-module,xxx)相应的模块。
这次真的长知识了~
最终的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 # 遍历Classes目录 ALLFILES = $(call walk, $(LOCAL_PATH)/../../Classes) FILE_LIST := hellocpp/main.cpp# 从所有文件中提取出所有.cpp文件 FILE_LIST += $(filter %.cpp, $(ALLFILES)) LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%) LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_network_static include $(BUILD_SHARED_LIBRARY) $(call import-module,.) $(call import-module,network) $(call import-module,extensions)
本文出自 “小狼Zer” 博客,请务必保留此出处http://9151482.blog.51cto.com/9141482/1623770
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。