Jump to content
  • Advertisement
Pilpel

Building Bullet Physics in Visual Studio - no need to link to libraries?

Recommended Posts

C++ newbie here,
It seems like I can build Bullet without linking to the three libraries (LinearMath.lib, BulletCollision.lib, BulletDynamics.lib) mentioned in every tutorial out there.
I simply #include <btBulletDynamicsCommon.h>, and add the the appropriate folders in the project, and everything runs great:

Image.jpg

Please explain to me what's going on here. Why did I have to build Bullet using CMake in the first place?

Thanks

Share this post


Link to post
Share on other sites
Advertisement

Are you adding the bullet CPP files to your project? If so, you don't have to link against the lib, because you're compiling and linking it from source code directly...

I actually do the same thing in my engine :D

Share this post


Link to post
Share on other sites

So the .lib's are basically just for including the headers? Why would anyone be so lazy to not include the .cpp files as well? 

Share this post


Link to post
Share on other sites
2 hours ago, Pilpel said:

So the .lib's are basically just for including the headers? Why would anyone be so lazy to not include the .cpp files as well? 

Libs are are basically a pile of precompiled CPP files. Usually when using external libraries, you will first compile them into libs, and then link those libs into your project. This keeps your project simple as your external libraries are all precompiled.

It also allows "closed source" libraries to keep their source code private if they like.

Share this post


Link to post
Share on other sites

OK

So bullet is a library. You need to follow its build instructions and build it using the program, CMAKE. (https://cmake.org/).


Cmake will generate a msvc solution file, which you open, and it will compile into a series of .libs. Open CMake, select the bullet folder as source, set the output path, this is where the libs and other *compiled* stuff will end up. 


You then link to them in your personal project. At the moment, as mentioned before, you are including bullet modules (.h/.cpp) in your project and that is the wrong method.

Edited by h8CplusplusGuru
clarified

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!