Snowcrash
Snowcrash

Reputation: 86097

Box2D compile errors

I've added Box2D to a Cocos2D project I'm working on.

I've followed several guides as to how to do this (all of which seem to differ!). However, none seem to work.

I'm getting these types of errors:

error: Box2D/Collision/b2BroadPhase.h: No such file or directory

I assumed I'd got the Header Search Paths wrong but have tried all sorts of variants with no luck.

Any suggestions?

Upvotes: 2

Views: 1974

Answers (2)

Adam
Adam

Reputation: 33126

Alternatively ... After a lot of trouble trying to include box2d in my project, I instead used box2d as a static library - takes a minute to setup, but it's much easier to maintain / add to multiple projects. Step by step guide here:

http://red-glasses.com/index.php/tutorials/box2d-for-ios-made-easy-make-it-a-static-library/

Upvotes: 0

Yannick Loriot
Yannick Loriot

Reputation: 7136

The easiest way to use Box2d with your project is to follow these lines:

  1. Copy the Box2d files into a subfolder of your project.
  2. Import these files into your project via Xcode.
  3. After in the "Project navigator", select your target and open the “Build Settings” tab.
  4. Set the "Always Search User Paths" to YES.
  5. Then search for the "User Header Search Path" and add this "${PROJECT_DIR}" (think to check the “recursive path“).

That's all! You just have to be careful when you want to use Box2d. Think to change the extension of your files from .m to .mm to warn the compiler that the class must be compile as Objective-C++ instead of Objective-C.

I have found a good tutorial here (with Xcode 3.2, but the idea is here). I hope it'll help you.

Upvotes: 6

Related Questions