mac下cocos2dx(带jsoncpp第三方库)编译为android项目心得
在mac下好不容写完了游戏,本以为轻轻松松就能编译为android项目,想不到弄了将近1整天才将问题解决
首先不带jsoncpp的编译方式请参考:http://www.bold-it.com/ios/cocos2d-x-box2d-iosandroid-hybrid-tutorial/
带jsoncpp第三方库的参考了http://blog.csdn.net/sniffer12345/article/details/7336732,对作者表示感谢。
我使用的是正常的jsoncpp版本,在jsoncpp文件夹内新建个Android.mk,内容为
- LOCAL_PATH := $(call my-dir)
- include $(CLEAR_VARS)
- LOCAL_MODULE := jsoncpp_static
- LOCAL_MODULE_FILENAME := libjsoncpp
- LOCAL_CPPFLAGS := -fexceptions
- LOCAL_SRC_FILES := src/lib_json/json_internalarray.inl \
- src/lib_json/json_internalmap.inl \
- src/lib_json/json_valueiterator.inl \
- src/lib_json/json_reader.cpp \
- src/lib_json/json_value.cpp \
- src/lib_json/json_writer.cpp
- LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/..
- LOCAL_C_INCLUDES := $(LOCAL_PATH)/..\
- $(LOCAL_PATH)/include \
- $(LOCAL_PATH)/src/lib_json
- include $(BUILD_STATIC_LIBRARY)
然后需要在proj.android/jni/Android.mk中修改配置,具体配置如下
- LOCAL_PATH := $(call my-dir)
- include $(CLEAR_VARS)
- LOCAL_MODULE := game_shared
- LOCAL_MODULE_FILENAME := libgame
- LOCAL_SRC_FILES := hellocpp/main.cpp \
- ../../Classes/AppDelegate.cpp \
- ../../Classes/BaseSprite.cpp\
- ../../Classes/GameLayer.cpp \
- ../../Classes/GameMenu.cpp \
- ../../Classes/GameScene.cpp \
- ../../Classes/JsonUtils.cpp \
- ../../Classes/LevelLayer.cpp \
- ../../Classes/LevelManager.cpp \
- ../../Classes/OptionScene.cpp \
- ../../Classes/SpriteFactory.cpp \
- ../../Classes/WelcomeLayer.cpp
- LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
- $(LOCAL_PATH)/../../libs/Box2d\
- $(LOCAL_PATH)/../../libs/jsoncpp/include/json/
- LOCAL_WHOLE_STATIC_LIBRARIES := jsoncpp_static cocosdenshion_static
- LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static
- LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static
- LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static
- include $(BUILD_SHARED_LIBRARY)
- $(call import-module,jsoncpp) \
- $(call import-module,CocosDenshion/android) \
- $(call import-module,cocos2dx) \
- $(call import-module,extensions) \
- $(call import-module,Box2D)
如果还是发生错误请参考第一个链接中的配置方式(非常重要)
摘自:http://blog.csdn.net/ashqal/article/details/8728269
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。