Hello
I searched for a solution for this all over the forums, but I found no solution so far.
What I am trying to do: create a project for iPhone and Android with Box2D support.
What I’ve done so far: create the project in Xcode, create Android project, merge them together. The directory structure is like this:
Game
- android
- ios
- Classes
- libs (contains cocos2dx, Box2D, etc)
What stops me: the Android code does not build when the compiler tries to build the libgame because:
SharedLibrary : libbox2d.so
Install : libbox2d.so => libs/armeabi/libbox2d.so
Compile++ thumb : game <= AppDelegate.cpp
In file included from /Users/clw/Projects/BoxGame/android/jni/helloworld/../../../libs/Box2D/Box2D.h:36,
from /Users/clw/Projects/BoxGame/android/jni/helloworld/../../../Classes/HelloWorldScene.h:13,
from /Users/clw/Projects/BoxGame/android/jni/helloworld/../../../Classes/AppDelegate.cpp:12:
/Users/clw/Projects/BoxGame/android/jni/helloworld/../../../libs/Box2D/Collision/Shapes/b2CircleShape.h:22:44: error: Box2D/Collision/Shapes/b2Shape.h: No such file or directory
In file included from /Users/clw/Projects/BoxGame/android/jni/helloworld/../../../libs/Box2D/Box2D.h:39,
from /Users/clw/Projects/BoxGame/android/jni/helloworld/../../../Classes/HelloWorldScene.h:13,
from /Users/clw/Projects/BoxGame/android/jni/helloworld/../../../Classes/AppDelegate.cpp:12:
/Users/clw/Projects/BoxGame/android/jni/helloworld/../../../libs/Box2D/Collision/b2BroadPhase.h:22:37: error: Box2D/Common/b2Settings.h: No such file or directory
/Users/clw/Projects/BoxGame/android/jni/helloworld/../../../libs/Box2D/Collision/b2BroadPhase.h:23:41: error: Box2D/Collision/b2Collision.h: No such file or directory
/Users/clw/Projects/BoxGame/android/jni/helloworld/../../../libs/Box2D/Collision/b2BroadPhase.h:24:43: error: Box2D/Collision/b2DynamicTree.h: No such file or directory
// goes on and on
As you can see, box2d is successfully built (I checked, it also shows up in libs/armeabi as libbox2d.so).
I inspected the tests directory and took note of how Box2D is referenced in the makefiles and made the following changes to my Android makefiles:
android/jni/Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
subdirs := $(addprefix $(LOCAL_PATH)/../../libs/,$(addsuffix /Android.mk, \
Box2D \ <<< added this line right here
cocos2dx \
CocosDenshion/android \
))
subdirs += $(LOCAL_PATH)/helloworld/Android.mk
include $(subdirs)
android/jni/Application.mk
APP_STL := stlport_static
APP_MODULES := cocos2d cocosdenshion box2d game
android/jni/helloworld/Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := game
LOCAL_SRC_FILES := main.cpp \
../../../Classes/AppDelegate.cpp \
../../../Classes/HelloWorldScene.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../libs/cocos2dx \
$(LOCAL_PATH)/../../../libs/cocos2dx/platform \
$(LOCAL_PATH)/../../../libs/Box2D \
$(LOCAL_PATH)/../../../libs/cocos2dx/include \
$(LOCAL_PATH)/../../../libs/CocosDenshion/include \
$(LOCAL_PATH)/../../../Classes
LOCAL_LDLIBS := -L$(call host-path, $(LOCAL_PATH)/../../libs/armeabi) \
-lGLESv1_CM \
-lbox2d \
-lcocos2d -llog -lcocosdenshion \
-L$(call host-path, $(LOCAL_PATH)/../../../libs/cocos2dx/platform/third_party/android/libraries) -lcurl
include $(BUILD_SHARED_LIBRARY)
Am I missing something? Was I supposed to add something to main.cpp? I tried adding both #include “Box2D/Box2D.h” and #include <Box2D/Box2D.h> but that’s not helping.
Thanks!