I am making a C++ project using SFML, ImGui and box2d. The first two of them work fine, but when I include box2d and use it, i get about 20 LNK2019 errors.
Maybe I should use another library? Or I have made any errors?
What am I using
- Visual Studio 2017
- box2d 2.4.1 (latest)
Additional Dependencies: Additional Include Directories:
Code
#include <box2d/box2d.h>
int main() {
b2World world(b2Vec2(0, -10));
b2BodyDef groundBodyDef;
groundBodyDef.position.Set(0.0f, -10.0f);
b2Body* groundBody = world.CreateBody(&groundBodyDef);
b2PolygonShape groundBox;
groundBox.SetAsBox(50.0f, 10.0f);
groundBody->CreateFixture(&groundBox, 0.0f);
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(0.0f, 4.0f);
b2Body* body = world.CreateBody(&bodyDef);
b2PolygonShape dynamicBox;
dynamicBox.SetAsBox(1.0f, 1.0f);
b2FixtureDef fixtureDef;
fixtureDef.shape = &dynamicBox;
fixtureDef.density = 1.0f;
fixtureDef.friction = 0.3f;
body->CreateFixture(&fixtureDef);
}
What I tried
- I used cmake-gui and Visual Studio 2017 to build box2d, ecerything was fine at this step and I didnt get any errors
- Then I copied
box2d.lib
frombin
folder of box2d build into my projectslib
folder - I also copied
include folder into my projects
include` folder - I set include and lib folder in my projects settings
- I repeated the Hello Box2D example from box2ds site
What actually happened
When I compiled the program I got 20 LNK2019 errors.
What I expected
I expected the program to compile and work.