最新的安卓ndk已經不需要cgywin的支持,可以在win32或64環境下直接編譯cocos2d-x的源碼,
但是其他很多小問題。
1》不要用eclipse直接看.cpp文件,這樣的話檢測到錯誤就不可以編譯成功, 貌似是應為利用ndk編譯沒有導入頭文件,顧cdt編譯時出現錯誤。
2》設置NDK_MODULE環境變量
導入工程後,開始進行環境配置,點testcpp->project->propertis->c++ build,
修改build command為G:\android\ndk\android-ndk-r9\ndk-build.cmd
然後就是修改android.mk
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := testcpp_shared LOCAL_MODULE_FILENAME := libtestcpp LOCAL_SRC_FILES := testcpp/main.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_WHOLE_STATIC_LIBRARIES := cocos_testcpp_common 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-add-path, G:/cocos2d-x-2.1.5)\ $(call import-add-path, G:/cocos2d-x-2.1.5\cocos2dx\platform\third_party\android\prebuilt)\ $(call import-module,samples/Cpp/TestCpp) $(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)
然後開始編譯,有問題歡迎留言。
本文出自 “Cocos2D-X” 博客,請務必保留此出處http://lonag.blog.51cto.com/3340984/1305060