How to include Box2d with v3.17?

How to include Box2d with v3.17?
0.0 0


I do not want to use the integrated physics, but create my own worlds and manipulate them separately.

In v3.13.1, to use Box2d, i simply had to do:

#include <Box2d/Box2d.h>

And everything seemed to work. I could create b2World etc.

I upgraded to 3.17, and it seems that there is an error when I try:

#include <Box2d/Box2d.h>

How do I include Box2d ?


i got the same error, i tryed everything but not fix it, and i used box2d in version 3.16 instead of 3.17 at last.


How are you obtaining Box2D?


I don’t do anything to obtain Box2d. In 3.13.1, all I had to do was type:

#include <Box2d/Box2d.h>

And I could use Box2d without any problem. Between 3.13.1 and 3.17, something has changed in how Box2d is included with cocos2d, so this is no longer possible.

I think when something like this is changed, documentation should be added in the gift book, so it’s easy to figure out how to do things like this.


So it means between 3.16 and 3.17 something was removed, so we cannot just directly use “include”.


@slackmoehrle in 2d-x 3.17, project has added the box2d header search path in build setting, so we only need to add the box2d .a file in Build Phases, and add the library search path in build setting, maybe there is something wrong in the hearder search paths.
The box2d’s head file is in the location “path/to/2d-x/external/Box2D/include/Box2D/Box2D.h”, two “Box2D” here, xcode only finds the first “Box2D” path, missing the second. <Box2D/Box2D.h> is not working.


Any suggestion?


We are having the same issue. Any suggestion?


ok, let me start looking at this more.


And make sure to compile with CC_ENABLE_BOX2D_INTEGRATION=1 (Windows)


I tried that, but it doesn’t help Xcode find Box2d. It still won’t compile since it can’t find the headers properly


Try adding this line as the image, maybe this will help:


I create an empty project with 3.17, and add box2D include path in setting like this:

but I still can not find the correct header file path in xcode:


v3.16 box2d

// Solve position constraints
bool positionSolved = false;
for (int32 i = 0; i < step.positionIterations; ++i)
	bool contactsOkay = contactSolver.SolvePositionConstraints();

	bool jointsOkay = true;
	for (int32 j = 0; j < m_jointCount; ++j)
		bool jointOkay = m_joints[i]->SolvePositionConstraints(solverData);  // here! line 317
		jointsOkay = jointsOkay && jointOkay;

line 317 => bool jointOkay = m_joints[ j ]->SolvePositionConstraints(solverData);
change i to j, it will be fine,I think.