Problem with linking under VS2010

Hi,

I succefully compiled Box2D after following the CMake and VS project steps and got the box2d.lib file.

Now in my project I've set the box2d.lib file as an additional dependency for the linker and made sure Visual Studio finds it. However, I keep getting the LNK2019 error, unresolved external symbol, as follows:

Code:
error LNK2019: unresolved external symbol "public: __thiscall b2World::b2World(struct b2Vec2 const &,bool)" (??0b2World@@QAE@ABUb2Vec2@@_N@Z)
error LNK2019:unresolved external symbol "public: void __thiscall b2World::Step(float,int,int)" (?Step@b2World@@QAEXMHH@Z)
error LNK2019: unresolved external symbol "public: class b2Body * __thiscall b2World::CreateBody(struct b2BodyDef const *)" (?CreateBody@b2World@@QAEPAVb2Body@@PBUb2BodyDef@@@Z)


I've searched through 8+ pages of the forum and around google, and found nothing. Can't understand what I'm doing wrong, I followed these steps:

- Download Box2D_v2.1.2.zip and extract it.
- Run Cmake-gui as explained in the .txt file.
- Open the solution, set Box2D as startup project, and press F7 (generate).
- Grab the box2d.lib file at the Debug directory (I'm compiling my project as Debug right now) and put it on one of the VS default library directories (did same thing for other libraries and worked fine, may the mistake be here?).
- Set the include directories.
- Add box2d.lib as additional dependency on the project.

Can anyone spot any mistake among those steps? Must be a silly thing, but can't find it.

Thank you very much for your help, I appreciate it a lot.
I'm not sure what the problem is, but I generally recommend you include the Box2D project in your solution. Having the source code in your project will help track down issues more efficiently.
Done that, still having the same problem though. It's really strange, if I can't get it to work I guess I'll have to compile Box2D with the project everytime :/

Thanks for your help!
Setting a project as a dependency doesn't automatically mean that whatever that project produces will be linked to - after all, the project might not even produce a .lib in the first place.
Even if the .lib is in the compiler's libs folder you will still need to specify that it should be linked to, otherwise everything you ever build would be linked to every .lib in that folder every time, and I'm pretty sure that's not the case.
Box2D is small enough that I usually keep all the source files directly in my project, any decent IDE will let you put them in a folder to keep things tidy.
I understand what you say there. But I specified the box2d.lib as a dependency in the Linker's Input options, thought that was enough to tell the linker to link it, so I am wrong?

If that's the case, do you know where can I actually specify the linker which libriaries to link in VS?

Still seems strange to me, though, because I linked the opengl and python libriaries this way already and it worked. Any ideas?

Can't say it enough, thanks for your help 🙂

EDIT:

Also, in the last part of your post, you mean you compile Box2d with your project? Does it take a lot or time or the difference is small?
Yes, compile all the Box2D files with my project - but a decent IDE will only compile them if they have actually been changed. If you don't edit them nothing needs to be compiled, they just need to be linked to which you are doing anyway.
i am also face this problem plz help.
I see, so if I don't change the Box2d code, VS will use the object files which are compiled just the first time.

Thanks for your help!

P.D: Anyway, if anyone finds out what the problem was just let me know, I'm still curious 🙂

Original thread: https://box2d.org/forum/viewtopic.php?t=7202