Problems with Object-C++ and Framework

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 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 of wax_start(). The easiest way to fix this is to tell the C++ compiler that everything in that header is pure C e.g.

extern "C"
 #import "Wax/whatever.h"

Don't use but stick with main.m. No need to rename main.m for Box2D. This works because you typically don't include/import any Box2D (C++) headers in main.m.

If you add Box2D (C++) header files to your prefix header, make sure they're only included in C++ (Objective-C++) files like so:

// C++ header files
#ifdef __cplusplus
#import "Box2D.h"
#endif // __cplusplus

Need Your Help

NUnit. Passing parameters into teardown method

c# unit-testing nunit nunit-2.5 teardown

I'm using NUnit. I have my test method defined likeso:

Quick insert TODO line

intellij-idea android-studio

Is it possible to setup IDEA to be able to quick insert // TODO lines? For example keybinding or code completion pattern? I didn't find anything.