I spent hours researching with Google and trying different ways of getting the Box2D source files to integrate with my codebase (which isn't much code, just a hello world). I know the Xcode's compiler can take C++, but when using the iPhone SDK's project that is not the case. I made sure not to change the physical folders and files, but moving the root "Include" and "Source" folders to my iPhone SDK's project and then referencing it by dragging and dropping to Xcode. When I added one line #import "Box2D.h" in my objective c file and then press "build", I get these errors below:
Code:
Line Location b2Math.h:23: error: cmath: No such file or directory
Line Location b2Math.h:24: error: cfloat: No such file or directory
Line Location b2Math.h:25: error: cstdlib: No such file or directory
Line Location b2Math.h:63: warning: implicit declaration of function 'finite'
Line Location b2Math.h:99: warning: no semicolon at end of struct or union
Line Location b2Math.h:99: error: syntax error before 'b2Vec2'
Line Location b2Math.h:102: error: syntax error before ':' token
Line Location b2Math.h:105: error: 'y' undeclared (first use in this function)
Line Location b2Math.h:105: error: 'x' undeclared (first use in this function)
Line Location b2Math.h:108: error: 'y' undeclared (first use in this function)
Line Location b2Math.h:108: error: 'x' undeclared (first use in this function)
Line Location b2Math.h:111: fatal error: method definition not in @implementation context
Line Location b2Math.h:111: error: syntax error before 'operator'
Line Location b2Settings.h:77: error: initializer element is not constant
Line Location b2Settings.h:87: error: initializer element is not constant
Line Location b2Settings.h:92: error: initializer element is not constant
Line Location b2Settings.h:107: error: initializer element is not constant
Line Location b2Settings.h:115: error: initializer element is not constant
Line Location b2Settings.h:122: error: initializer element is not constant
Line Location b2Settings.h:162: warning: type defaults to 'int' in declaration of 'b2_version'
Line Location b2Settings.h:162: error: syntax error before 'b2_version'
Line Location b2Settings.h:162: warning: data definition has no type or storage class
I also try changing the path for "No such file or directory" like this:
Code:
#import "c++/4.0.0/cmath.h"
But, it didn't work, I got more errors coming from the "cmath.h" itself.
I look into using "dylib" compiled from the Box2D project, but it is whole another problem.
About my macbook's:
Mac OS X 10.5.4 , Xcode 3.1, iPhone SDK 2.0
Please help! Thanks!