Search code examples
c++cocos2d-xunresolved-externalcocos2d-x-3.0

cocos2d-x and box2d linking error


I have troubles working in cocos2d-x v3. Actually, I want to init box2d world object. I have created my game project properly, as it was given in cocos2d-x manual. Now what's the trouble:

b2Vec2 gravity = b2Vec2(0.0f, -10.0f);
b2World world(gravity);

In this code the second line gives the compiler

'unresolved external symbol error':(

Without instantinating b2World object, everything compiles and works fine.

Have anybody faced this problem?


Solution

  • This is a very common linker error in Visual Studio and you have to add libbox2d.lib in your project properties.

    Right Click Project -> Project Properties -> Linker -> Input -> Additional Dependencies

    Now edit and add libbox2d.lib at the end and run project again.