Posts Tagged glui.h

Cocos2D and Box2D Compilation Errors

This is just to help those that have run into a whole slew of linking and other errors when attempting to add the cocos2d and Box2d frameworks directly into your project.

This information is pertinent for:

#define COCOS2D_VERSION 0x00009904

Cocos2d is easy enough to get to compile into your project.  Dealing with Box2d is entirely more complicated if you don’t understand how the file inclusions work.  Because of the location of the Box2D.h file you’ll quickly find yourself in a nearly endless conundrum of mismapped linking…

Here is how my project is currently setup:

Cocos2D with Box2D Project Groups

As you can see I have created the Box2D and Cocos2D directories as groups.

The actual file system looks like (I created the lib folder):

which contains the following directories copied directly from the cocos2D download source package:  cocos2d and   external
Take careful note that I have removed the “TestBed” in order to avoid the missing “glui.h” issues!
So even with this setup I still was receiving over 5000 nasty Box2D errors.  Here is the fix I found to work.
  1. Go to Project -> Edit Active Target “myCocos2DProject”
  2. Select the Build tab.
Edit XCode Project Settings
Check the “Always Search User Paths
And add in the “lib/external/Box2d/**” into the “User Header Search Paths”  Pro Tip: When adding the header search paths, make sure that you have the recurse check box selected.
That is all you have to so to fix the issue!
One final super pro tip:  Make sure that your .m files are renamed to .mm in order to get the C++ libraries working.  You will have to rename the AppDelegate_iPhone.m to  (Otherwise you’ll see errors like:  cassert no such file or directory, etc.)
Happy Box2D coding.

, , , ,

1 Comment