首页 > 代码库 > mac下cocos2dx(带jsoncpp第三方库)编译为android项目心得
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,内容为
[plain] view plaincopy
- 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中修改配置,具体配置如下
[plain] view plaincopy
- 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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。