Creating a project from scratch
From Physics Simulation Wiki
Creating a project from scratch using Visual Studio (any version)
Note: C++ is not included in Visual Studio 2015 by default and has to be manually selected during installation. 
- Download the Bullet source code from https://github.com/bulletphysics/bullet3/releases/latest and unpack the archive somewhere, say C:\Users\Dev\Desktop, so the root of Bullet is in C:\Users\Dev\Desktop\bullet3 (replace "Dev" with your username).
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.
- Start CMake-gui.
- Choose the location where you unpacked the Bullet source code and where you build the binaries for your own project, then press Configure.
- Choose the compiler, such as Microsoft Visual Studio 2015.
- Review the settings and press Configure again.
- Make sure the run-time library is the same as in your project. By default it is set to the multi-threaded, static version (/MT, USE_MSVC_RUNTIME_LIBRARY_DLL is unchecked). Then press Generate.
- Optionally, you could open the generated project solution (in our case C:\Users\Dev\Desktop\tutorial\build\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:\Users\Dev\Desktop\tutorial called BulletTestApp, located in C:\Users\Dev\Desktop\tutorial
- Hit Finish.
- Just try to build it without any change.
- Now add the generated project files 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.vxcproj, and same for src/BulletDynamics/BulletDynamics.vcxproj and src/LinearMath/LinearMath.vcxproj:
- For Visual Studio 2010 and above, add project references to Bullet libraries.
When you get the error The project file has been moved renamed or not on your computer, check the References for the newly added project. Removes references to 'ZERO_CHECK'.
- For Visual Studio 2008, you might instead need to enable the Link Library Dependencies setting for all projects, in the linker settings:
- Make sure to make your program dependent on the Bullet libraries. Go to Project Dependencies
- and select the Bullet libraries:
- Now set the header include path to the 'src' folder within Bullet source code, for example C:\Users\Dev\Desktop\bullet3\src in our case. Go to Project Properties.
- Go to C/C++, Additional Include Directories. For all configurations, type/browse to the Bullet3/src folder, in our case C:\Users\Dev\Desktop\bullet3\src.
- If USE_MSVC_RUNTIME_LIBRARY_DLL was not selected above, the project must use the non-DLL runtime library - Multi-threaded (/MT). Otherwise, use Multi-threaded DLL(/MD). For debug configurations, use the debug version of the runtime library.
- 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:
- Recursively add all .cpp files from the Bullet/src folder to your project
- Build and debug your project.
Creating a project from scratch using Eclipse (Linux)
Work in progress.
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:
- Update 12/17/2010: If you are having trouble with the following build errors:
"btTypedConstraint::serialize(void*, btSerializer*) const", referenced from:
"btAlignedFreeInternal(void*)", referenced from:
then you have to include the Bullet frameworks in your Xcode project. Make sure they are built and installed like this (This is without Xcode, maybe there is some way to make them in Xcode too, I don't know):
cmake . -G "Unix Makefiles" -DINSTALL_LIBS=ON -DBUILD_SHARED_LIBS=ON \ -DFRAMEWORK=ON -DCMAKE_OSX_ARCHITECTURES='i386;x86_64' \ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/Library/Frameworks \ -DCMAKE_INSTALL_NAME_DIR=/Library/Frameworks -DBUILD_DEMOS:BOOL=OFF make -j4 sudo make install
This will put the Bullet frameworks in /Library/Frameworks. Navigate there in the finder and then drag the frameworks into your Xcode project. You need at least LinearMath.framework and BulletDynamics.framework. (Those two will fix the above linking errors.) But you probably also want BulletCollision.framework and maybe others.
If you have set up the frameworks like this, you don't have to change the header search path as above. Instead you can put this include line and Xcode will find the headers inside the framework:
- From here, continue to the Hello World tutorial.
Unix, Linux, MinGW etc
Follow the generic make recipe from the installation guide making sure the .a files are built. From there, when creating a Makefile, in the gcc arguments, make sure you add in a -I bullet_dir for the headers and also add in libBulletDynamics.a, libBulletCollision.a and libLinearMath.a or whatever you're using.
For example (assuming the src dir is in the folder bullet):
gcc myprogram.cpp -lGL -lGLU -I ./bullet/ ./bullet/BulletDynamics/libBulletDynamics.a ./bullet/BulletCollision/libBulletCollision.a ./bullet/LinearMath/libLinearMath.a
Link order for libraries
Note that many compilers the link order matters, so make sure to use the following order of libraries:
- BulletMultiThreaded (optional)
- MiniCL (optional)
- BulletWorldImporter (optional)
- BulletSoftBody (optional)