simple step by step: how do I include Box2d in my project?

language: c++
environment: xCode 4
version of Box2D: 2.2.1

I just need some idea of how to add box2d to my current project…
I've tried everything I can think of: adding the source files to my project, making a libBox2d.a file and adding that… I've also tried adding the Box2d directory to my "header search paths" but everything I do just results in header files that can't be found…

i think I'm missing something very simple. so just a simple step by step would be amazing… everything else I've found on the internet is for different versions of either Xcode or box2d and none of them work… I don't know what else to do. been pulling my hair out for days.
I think that version of Box2D comes with an Xcode project file. You can see how that is set up.
It could just be that your header search paths setting is one level off... Box2D source is set up to be included as:

#include <Box2D/Box2D.h>

...so your header search path should specify the folder above where the Box2D.h file is, not the actual folder that contains it.
http://www.iforce2d.net/b2dtut/setup-ios
Erin Catto wrote:
I think that version of Box2D comes with an Xcode project file. You can see how that is set up.

I found the Xcode project file, I just have no idea what to do with it. i mean, it runs and everything, but how does that help me exactly? how do i get the box2d library in my own project?
thanks,
irresistible force wrote:
It could just be that your header search paths setting is one level off... Box2D source is set up to be included as:

#include <Box2D/Box2D.h>

...so your header search path should specify the folder above where the Box2D.h file is, not the actual folder that contains it.
http://www.iforce2d.net/b2dtut/setup-ios


ok. I changed my #include to the one you said above and changed my header search path from "Box2D" to "./". the code compiles now and no longer gives me all those linker errors! woot! 😀. but now xCode is giving me a "Apple Mach-O Linker (Id) Warning" it says "ld: warning: directory not found for option '-L/Users/dylpickler/Programs/The Deep Project/The Deep Project/Box2D'"

I also tried "../" as my header search path and got the same result then I tried changing my include back to #include "Box2D.h" and it still runs, it just gives that warning do you have any idea what that warning means? i seem to be able to access box2d functions and use them now, so I'm not sure what its complaining about. thanks so much
nevermind… turns out the error was left over from one of my previous attempts to fix this issue.
thanks for all your help and the quick replies folks.

if anyone else is reading this and trying to learn from my mistakes and they want a step by step, heres what I ended up doing: I put the Box2D folder (the one with the Box2D.h file and all the source files in sub folders) not in the folder with all my source files for my project, but the folder above that, the one with my Xcode project file in it. Inside Xcode I clicked "Add files to project" and chose that same box2d folder. then under project build settings, I changed "always search user paths" to yes and I double clicked on "user header search paths" and put in
Code:
./
as my path and checked the recursive box.
I've found that if you create a project using a cocos2d template and you include the box2d source, the build search paths in 'Build Settings' are filled in with 'YES' for 'Always Search Users Paths' and 'User Header Search Paths' always contain your project directory name and /libs... Example: If your projects directory name is 'MyBox2D' then the 'User Header Search Paths should read: 'MyBox2D/libs'. I've found that this works every time for me when I include cocos2D Box2D source in XCode 4.2 using iOS 5. 😎

Original thread: https://box2d.org/forum/viewtopic.php?t=7812