Wednesday 11 July 2012

Create a Bullet Physics library for IOS, iPhone, IPad, Xcode

This is a rough run down, on how I get the Bullet Physics library working within my applications.


First of all I find out what is the latest stable build by going to


http://code.google.com/p/bullet/downloads/list


At current it is


Bullet 2.80 Physics SDK SP1 (svn r2531)  


Don't download this library we will get hold of it by SVN.


This gives me the current revision number


I then create  a directory where I would like to build the libraries.


from the terminal I go to my main build directory and create a new one for my bullet library


mkdir ./Bullet2.8-2531


I now use a build script written by Hoon Hwangbo


cd ./Bullet2.8


git clone git@github.com:Eonil/Bullet-PhysicsEngine-BuildScript-iOS.git


Now you need to update the build script to use the latest revision.


vi ./Bullet-PhysicsEngine-BuildScript-iOS/Script/BuildAll.sh


Find the line that reads


svn            checkout http://bullet.googlecode.com/svn/trunk/ -r 2440 ./Source


and replace 2440 ( the revision number when the script was written) with 2531 (the current revision number)


save your file and exit vi (or whatever program you are using)


Now compile your library


sh ./Bullet-PhysicsEngine-BuildScript-iOS/Script/BuildAll.sh ./Build


Now I create a new project in Xcode ( I generally use a cocos3d template)


Now click on your target and goto "Linked Frameworks and Libraries"
Click + then add other, navigate to your compiled libraries directories and add the libraries you require, as a guide go for

  • libBulletCollision.a
  • libBulletDynamics.a
  • libBulletMultiThreaded.a
  • libBulletSoftBody.a
  • libLinearMath.a
  • libMiniCL.a
This does seem to manually add your directory settings to your build configuration but I still add my main directory (probably not needed)


So I go to my target, click on build settings and locate "User Header Search Paths"
I then add the path to my Package directory. 


Now all I have to do within my code is import the header as follows



#import "btBulletCollisionCommon.h"

Finally rename your .m files that include the header to .mm to allow for the inclusion of external c++ code.


You should now be able to build your project.

I hope this was of some help.


**Note at current this only works on the device, I have managed to get this working not he simulator, but need to simplify it before adding the instructions.

Duncan.















2 comments:

  1. Wow, What a Excellent post. I really found this to much informatics. It is what i was searching for.I would like to suggest you that please keep sharing such type of info.Visit here for Penetration testing services and Software testing services

    ReplyDelete