Cocos2d-x for android 使用Box2d报错解决

环境:2dx-1.0.1-x-0.11.0 +win7+vs+cywin

在win下开发使用box2d不会报错

但是to android的时候编译会出错 因为2dx for android 工程并没有加入Box2D库

需要修改下列文件(加入红色部分):

jni目录下

Application.mk

APP_MODULES := cocos2d box2d cocosdenshion game_logic game

Android.mk
subdirs := $(addprefix $(LOCAL_PATH)/。。/。。/,$(addsuffix /Android.mk, \
           cocos2dx \
           Box2D \
           CocosDenshion/android \

))

helloworld里面的Android.mk

                    $(LOCAL_PATH)/。。/。。\
                     $(LOCAL_PATH)/。。/。。/Classes

LOCAL_LDLIBS := -L$(call host-path, $(LOCAL_PATH)/。。/。。/libs/$(TARGET_ARCH_ABI)) \
                -lcocos2d -llog -lgame_logic -lbox2d

 

Classes里面的Android.mk

LOCAL_C_INCLUDES := $(LOCAL_PATH)/。。/。。/cocos2dx \
                                    $(LOCAL_PATH)/。。/../     \
                                    $(LOCAL_PATH)/。。/../Box2D \   

                                 LOCAL_LDLIBS := -L$(call host-path, $(LOCAL_PATH)/../android/libs/$(TARGET_ARCH_ABI)) \
                               -lcocos2d -lcocosdenshion -lbox2d \

      这样就可以了

     ps.如果提示导入box.h错的 主要是修改一下BOX2D的位置    $(LOCAL_PATH)/。。/../Box2D \ 就可以了   

    最后。。自己转换到..  因为blog显示不了 /。。  就好像这样$(LOCAL_PATH)/.. /http://www.cnblogs.com/汗死( ⊙ o ⊙ )啊!             

    

 

你可能感兴趣的:(cocos2d-x)