因为前段时间都在用quick,所以对C++这边又感觉陌生。最近在写项目,用C++的,编译的时候遇见蛋疼的问题,也怪我缺乏经验。。。
LOCAL_PATH:=$(callmy-dir) include$(CLEAR_VARS) LOCAL_MODULE:=cocos2dcpp_shared LOCAL_MODULE_FILENAME:=libcocos2dcpp #遍历目录及子目录的函数 definewalk $(wildcard$(1))$(foreache,$(wildcard$(1)/*),$(callwalk,$(e))) endef #遍历Classes目录 ALLFILES=$(callwalk,$(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) $(callimport-module,2d) $(callimport-module,audio/android) $(callimport-module,Box2D) $(callimport-module,network) $(callimport-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:=$(callmy-dir) include$(CLEAR_VARS) $(callimport-add-path,$(LOCAL_PATH)/../../cocos2d) $(callimport-add-path,$(LOCAL_PATH)/../../cocos2d/external) $(callimport-add-path,$(LOCAL_PATH)/../../cocos2d/cocos) LOCAL_MODULE:=cocos2dcpp_shared LOCAL_MODULE_FILENAME:=libcocos2dcpp #遍历目录及子目录的函数 definewalk $(wildcard$(1))$(foreache,$(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) $(callimport-module,.) $(callimport-module,extensions)原文链接:https://www.f2er.com/cocos2dx/343834.html