最新的安卓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)
然后开始编译,有问题欢迎留言。
long原创
转载于:https://blog.51cto.com/lonag/1305060