Search code examples
xcodexcode4cocos2d-iphonebox2d

Compiling Box2D in Xcode, build directory issues


I'm a bit stuck here, basically I'm trying to compile Box2D as a static cocos library. I started by creating a static library project in xcode4 and dragged in the source files (in the correct folder hierarchy) into the project. When I compile though I get a whole load of errors in regards to the header files not being found.

So all these header files being looked for in b2GearJoint.cpp are not found:

#include <Box2D/Dynamics/Joints/b2GearJoint.h>
#include <Box2D/Dynamics/Joints/b2RevoluteJoint.h>
#include <Box2D/Dynamics/Joints/b2PrismaticJoint.h>
#include <Box2D/Dynamics/b2Body.h>
#include <Box2D/Dynamics/b2TimeStep.h>

I figured this should be straight forward enough to fix, I just need to include the root box2d folder in the pre-included directories so it knows where to look. So I added the project root directory to the search path header section but i still get the same errors.

This may actually have a straightforward solution but I'm new to xcode 4 (usually a visual studio user)...


Solution

  • For Box2D you will have to add the Box2D path to the "User Header Search Paths" and not the "Header Search Paths" (without "User") setting.

    This is because Box2D uses the angle bracket includes throughout the code instead of the more correct "file.h".