I have this project that needs to integrate Box2D, Cocos2d-iPhone and iPhone wax. At first I put cocos2d-iphone and box2d together, and it gives me this error message:
fatal error: 'cassert' file not found
#include <cassert>
^
And I search and found out it's because box2d is written in c++, and you have to set all source files referring to box2d to *.mm, so apple compiler can compile it as object-c++.
So I just changed every source files into *.mm and it worked.
And then I tried to get iPhone wax into it. iPhone wax is written in object-c and c. And they provide a wax.framework. So I download it and drag it into my project's frameworks zone. And it gives me this error:
"__Z9wax_startPcPFiP9lua_StateEz", referenced from:
_main in main_old.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
so I search again and I find out it's because of the expected library does not exist. And I check list by list and I am pretty sure every setting is correct and I could not find the problem.
So I did some test. I create a new and sample project from one of those templates, and I put iPhone wax into it and it works fine. And then I changed the main.m file into main.mm and it gives the error just like above.
So how do I fix this? Is this because object-C++ can't import a object-c and c framework? Should I just recreate the framework and change all their names to *.mm? Or did I do wrong when I changed my source files into *.mm and there should be a better way of solving it?
That function is actually a function called
wax_start()
. All the other crap is name mangling added by the C++ compiler. This is needed to support overloading i.e. the other crap encodes the parameter and return types ofwax_start()
. The easiest way to fix this is to tell the C++ compiler that everything in that header is pure C e.g.