Creating a project from scratch
From Physics Simulation Wiki
Contents |
Creating a project from scratch using Visual Studio (any version)
Download and install Bullet
- Download the Bullet source code from http://code.google.com/p/bullet/downloads/list and unzip the archive somewhere, say c:\develop, so the root of Bullet is in c:\develop\bullet-2.76
Download and install cmake
- The recommended way to start a new project from scratch is using cmake. Download cmake from http://cmake.org and install it.
Run CMake-gui
- Start CMake-gui
- Choose the location where you unzipped the Bullet source code, and where you build the binaries for your own project and press Configure
- Choose the compiler, such as Microsoft Visual Studio 2008
- Review the settings and press Configure again
- Make sure the Run-time library is the same as your project (by default it is set to Run-time library DLL) and press Generate
- Optionally, you could open the generated project solution (in our case C:\develop\tutorial\BulletBuild\BULLET_PHYSICS.sln) and build the library and demos, but this is not necessary
Create a new Visual Studio project
- Now create your new project, say a Win32 Console Application in c:\develop called BulletTestApp, located in c:\develop\BulletTestApp:
- Hit Finish
- Just try to build it without any change
- Now add the generated projectfiles for the Bullet libraries, BulletCollision, BulletDynamics and LinearMath:
- Browse to the folder where you selected CMake-gui to build the binaries, then select src/BulletCollision/BulletCollision.vcproj, and same for src/BulletDynamics/BulletDynamics.vcproj and src/LinearMath/LinearMath.vcproj:
- Make sure to make your program dependent on the Bullet libraries, right click on your project, select 'Dependencies'
- and select the Bullet libraries:
- Now set the header include path to the 'src' folder within Bullet source code, for example c:\develop\bullet-2.76\src in our case. Right click on your project, select 'Properties'
- Goto C/C++, Additional Include Directories, and type/browse to the Bullet/src folder, in our case c:\develop\bullet-2.76\src
- Repeat those steps for all configurations (Debug, Release etc), and start programming
- From here, you could try out the Hello World tutorial
Alternative, manual method
If you do not want to use cmake, here is another simple method. Assuming you have unzipped Bullet in C:\bullet-2.75\, adjust all pathnames if necessary:
- Create a new, empty C++ project (File > New > Project: Choose Project types > Visual C++ > General > Empty Project)
- Add a new C++ file (e.g. "main.cpp") to your project and copy the code from the Hello World page into it and save it.
- Open the properties of your project (in the Solution Explorer right-click the project name and select Properties, or in the Property Manager double-click Debug|Win32):
- In Configuration Properties > C/C++ > General > Additional Include Directories add:
C:\bullet-2.75\src - Recursively add all .cpp files from the Bullet/src folder to your project
- Build and debug your project.
Creating a project from scratch using XCode
Assume we downloaded bullet-2.x.tgz and unzipped it into a folder /Users/name/develop, we will have for example: /Users/name/develop/bullet-2.76
- Create a new C++ console application, using XCode:
- put it in next to bullet-2.x, in the develop folder:
- Open the main.cpp file and add #include "btBulletDynamicsCommon.h":
- Edit the project settings for All Configurations
- Add the bullet-2.x/src folder:
- Now build the project:






