How to include Box2d with v3.17?

Thank you! It works!

Iā€™m now experiencing this issue as well with version 3.17 and it seems that the Box2d headers were removed from the /external/ folder. The only Box2d file I can find in the cocos project is /Frameworks/libbox2d.a. So the previous suggestion to add a search path to a header which no longer exists cannot work.

Just download Cocos2dx v3.17 from the download section of this website. there is a ā€œ/external/Box2Dā€ folder. 100%!

I added two lines in Android.mk
ā€¦
LOCAL_C_INCLUDES += $(LOCAL_PATH)/ā€¦/ā€¦/ā€¦/cocos2d/external/Box2D/include
ā€¦
LOCAL_WHOLE_STATIC_LIBRARIES := box2d_static
ā€¦

itā€™s the same for xcode projects. add box2d paths to ā€œHeader Search Pathsā€ + If you cant find the Box2d folder in your project navigatorā€¦ you had also to add the folder to your project)

Enable Box2D in your Project:
xcode: CC_ENABLE_BOX2D_INTEGRATION=1 (search for ā€œPreprocessor Macrosā€ under Build Settings)
android: APP_CPPFLAGS += -DCC_ENABLE_BOX2D_INTEGRATION=1 (Application.mk)

In your Code use it like : #include "Box2D/Box2D.h"

it works!

Has anyone included Box2D for a Mac project?
On iOS it works for me:

But when i try to compile in Mac, iā€™ve the same problem:

#include <Box2D/Box2D.h>

'Box2D/Box2D.h' file not found

cc @slackmoehrle

It should work for Mac also.
Please check what that include is added for Mac project settings.

Mac project settings?
Where?

Select target Mac and then check project settings
https://static1.squarespace.com/static/50c25455e4b0ef5720704c6b/t/541b040be4b07b5243aff3cc/1411056655739/

Hmmā€¦
In Build Settings > Header Search Paths i added
$(PROJECT_DIR)/../cocos2d/external/Box2D/include

I added it in the scheme MyGame-desktop instead of the scheme MyGame-mobile.
Is that what youā€™re trying to say?
If yes, it doesnā€™t work.

Iā€™m using CocoaPods in the project. In Podfile i configured only MyGame-mobile.
But box2d is another thingā€¦ (no pods).

Sure. Itā€™s a setting problem in my projectā€¦ iā€™m sure.

@dimon4eg you could reproduce my error creating a new cocos project.
In HelloWorld.cpp add this line:

#include <Box2D/Box2D.h>

After that, compile it (in mobile). You will see the error.
Then edit Build Settings > Header Search Paths and add
$(PROJECT_DIR)/../cocos2d/external/Box2D/include

Compile again. It will work.
Now change scheme to MyGame-desktop and compile in your Mac,

You will see the error again.
Andā€¦ thenā€¦ how to fix it on desktopā€¦?

EDIT: adding the header search path in MyGame-desktop, clean & re-build, now works in cpp-example but not in my original projectā€¦ :triumph:

Do you have a Desktop target? Did you add the Box2D path there too?

yep. :confused:

Maybe something with another lib, framework, etcā€¦

Undefined symbols for architecture x86_64:
 .
 .
 .
 .
 .
      ...
  "_objc_msgSendSuper2", referenced from:
      -[GLFWWindowDelegate initWithGlfwWindow:] in libcocos2d Mac.a(cocoa_window.m.o)
      -[GLFWContentView initWithGlfwWindow:] in libcocos2d Mac.a(cocoa_window.m.o)
      -[GLFWContentView dealloc] in libcocos2d Mac.a(cocoa_window.m.o)
      -[GLFWContentView updateTrackingAreas] in libcocos2d Mac.a(cocoa_window.m.o)
      -[GLFWApplication sendEvent:] in libcocos2d Mac.a(cocoa_window.m.o)
      -[NSTimerWrapper initWithTimeInterval:callback:] in libcocos2d Mac.a(AudioCache.o)
      -[NSTimerWrapper dealloc] in libcocos2d Mac.a(AudioCache.o)
      ...
  "_objc_msgSend_stret", referenced from:
      -[GLFWWindowDelegate windowDidResize:] in libcocos2d Mac.a(cocoa_window.m.o)
      -[GLFWWindowDelegate windowDidMove:] in libcocos2d Mac.a(cocoa_window.m.o)
      __glfwPlatformGetWindowPos in libcocos2d Mac.a(cocoa_window.m.o)
      -[GLFWWindowDelegate windowDidBecomeKey:] in libcocos2d Mac.a(cocoa_window.m.o)
      __glfwPlatformSetCursorMode in libcocos2d Mac.a(cocoa_window.m.o)
      -[GLFWContentView mouseMoved:] in libcocos2d Mac.a(cocoa_window.m.o)
      -[GLFWContentView viewDidChangeBackingProperties] in libcocos2d Mac.a(cocoa_window.m.o)
      ...
  "_uncompress", referenced from:
      cocos2d::ZipUtils::inflateCCZBuffer(unsigned char const*, long, unsigned char**) in libcocos2d Mac.a(ZipUtils.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)