因为前段时间都在用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)
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。