您好,登錄后才能下訂單哦!
因為前段時間都在用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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。