0

I would like to add Box2D to my project using vcpkg but it seems certain files aren't linking.

To do so I run .\vcpkg install box2d --triplet x64-windows and copy the values mentioned into my CMakeLists.txt.

find_package(box2d CONFIG REQUIRED)
target_link_libraries(main PRIVATE box2d::box2d)

After doing this I can include box2d/box2d.h.

#include "box2d/box2d.h"

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

However this error is thrown.

undefined reference to `b2World::b2World(b2Vec2 const&)'

What else am I missing to get this working?

Michael
  • 3,411
  • 4
  • 25
  • 56
  • 1
    You should check to see what exact libraries are linked to your executable. This may be a bug in the port file that you should report at the github site. – drescherjm Jan 31 '22 at 21:01
  • 1
    Is this question actually a duplicate? The error is the same as mentioned in the referred question however I'm asking about vcpkg and how it isn't right after installing. I don't see how the referred question helps me. – Michael Jan 31 '22 at 22:13
  • 3
    I am with you , thats a kneejerk duplicated close, without reading the question, you got my vote to reopen. If it doesnt get reopened change the title to something like 'vcpkg fails to find library', sadly I cant help you as I dont know cmake or vcokg very well – pm100 Jan 31 '22 at 22:37

0 Answers0