Advertisement

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

Started by July 30, 2017 10:04 PM
4 comments, last by h8CplusplusGuru 7 years, 3 months ago

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

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

Advertisement

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? 

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.

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.

This topic is closed to new replies.

Advertisement