Creating a project from scratch

From Physics Simulation Wiki

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 +
= Creating a project from scratch using Visual Studio 2008 =
-
=Creating a project from scratch using Visual Studio 2008 =
+
== 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
-
* The recommended way to start a new project from scratch is using cmake. Just have a look at the Bullet/Demos/HelloWorld/CMakeLists.txt.  
+
== 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
 +
 
 +
<center>[[Image:start_cmake.PNG]]
 +
</center>
 +
 
 +
* Choose the location where you unzipped the Bullet source code, and where you build the binaries for your own project and press Configure
 +
<center>[[Image:cmake_step0.PNG]]
 +
</center>
 +
 
 +
* Choose the compiler, such as Microsoft Visual Studio 2008
 +
<center>[[Image:cmake_step1.PNG]]
 +
</center>
 +
 
 +
* Review the settings and press Configure again
 +
<center>[[Image:cmake_step2.PNG]]
 +
</center>
 +
 
 +
* 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
 +
<center>[[Image:cmake_step3.PNG]]
 +
</center>
 +
 
 +
* 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:
 +
 
 +
<center>[[Image:step1.PNG]]
 +
</center>
 +
 
 +
* Hit Finish
 +
 
 +
<center>[[Image:step2.PNG]]
 +
</center>
 +
 
 +
* Just try to build it without any change
 +
 
 +
<center>[[Image:step3.PNG]]
 +
</center>
 +
 
 +
* Now add the generated projectfiles for the Bullet libraries, BulletCollision, BulletDynamics and LinearMath:
 +
 
 +
<center>[[Image:step4.PNG]]
 +
</center>
 +
 
 +
* 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:
 +
 
 +
<center>[[Image:step5.PNG]]
 +
</center>
 +
 
 +
* Make sure to make your program dependent on the Bullet libraries, right click on your project, select 'Dependencies'
 +
 
 +
<center>[[Image:step6.PNG]]
 +
</center>
 +
 
 +
* and select the Bullet libraries:
 +
 
 +
<center>[[Image:step7.PNG]]
 +
</center>
 +
 
 +
* 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'
 +
 
 +
<center>[[Image:step8.PNG]]
 +
</center>
 +
 
 +
* Goto C/C++, Additional Include Directories, and type/browse to the Bullet/src folder, in our case c:\develop\bullet-2.76\src
 +
 
 +
<center>[[Image:step9.PNG]]
 +
</center>
 +
 
 +
* Repeat those steps for all configurations (Debug, Release etc), and start programming
 +
 
 +
<center>[[Image:step10.PNG]]
 +
</center>
 +
 
 +
* 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 <tt>C:\bullet-2.75\</tt>, adjust all pathnames if necessary:
If you do not want to use cmake, here is another simple method. Assuming you have unzipped Bullet in <tt>C:\bullet-2.75\</tt>, adjust all pathnames if necessary:
Line 8: Line 94:
* 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.
* 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):
* 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: <tt>C:\bullet-2.75\src
+
* In Configuration Properties > C/C++ > General > Additional Include Directories add: <source lang=dos>C:\bullet-2.75\src</source>
* Recursively add all .cpp files from the Bullet/src folder to your project
* Recursively add all .cpp files from the Bullet/src folder to your project
* Build and debug your project.
* Build and debug your project.
-
=Creating a project from scratch using XCode  =
+
= 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.72
+
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:
* Create a new C++ console application, using XCode:
-
[[Image:newxcodeproject.png]]
+
 
-
* put it in next to bullet-2.x, in the develop folder:
+
<center>[[Image:newxcodeproject.png]]
 +
</center>
 +
 
 +
* put it in next to bullet-2.x, in the develop folder:
 +
<center>
[[Image:developfolder.png]]
[[Image:developfolder.png]]
 +
</center>
* Open the main.cpp file and add #include "btBulletDynamicsCommon.h":
* Open the main.cpp file and add #include "btBulletDynamicsCommon.h":
 +
<center>
[[Image:addcommoninclude.png]]
[[Image:addcommoninclude.png]]
 +
</center>
* Edit the project settings for All Configurations
* Edit the project settings for All Configurations
 +
<center>
[[Image:editxcodeprojectsettings.png]]
[[Image:editxcodeprojectsettings.png]]
 +
</center>
* Add the bullet-2.x/src folder:
* Add the bullet-2.x/src folder:
 +
<center>
[[Image:addbulletsrcinclude.png]]
[[Image:addbulletsrcinclude.png]]
 +
[[Image:addbulletsrcinclude1.png]]
[[Image:addbulletsrcinclude1.png]]
 +
</center>
* Now build the project:
* Now build the project:
 +
<center>
[[Image:buildxcode.png]]
[[Image:buildxcode.png]]
 +
/<center>
From here, continue to the [[Hello World]] tutorial.
From here, continue to the [[Hello World]] tutorial.

Revision as of 20:38, 16 February 2010

Contents

Creating a project from scratch using Visual Studio 2008

Download and install Bullet

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
Image:start_cmake.PNG
  • Choose the location where you unzipped the Bullet source code, and where you build the binaries for your own project and press Configure
Image:cmake_step0.PNG
  • Choose the compiler, such as Microsoft Visual Studio 2008
Image:cmake_step1.PNG
  • Review the settings and press Configure again
Image:cmake_step2.PNG
  • 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
Image:cmake_step3.PNG
  • 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:
Image:step1.PNG
  • Hit Finish
Image:step2.PNG
  • Just try to build it without any change
Image:step3.PNG
  • Now add the generated projectfiles for the Bullet libraries, BulletCollision, BulletDynamics and LinearMath:
Image:step4.PNG
  • 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:
Image:step5.PNG
  • Make sure to make your program dependent on the Bullet libraries, right click on your project, select 'Dependencies'
Image:step6.PNG
  • and select the Bullet libraries:
Image:step7.PNG
  • 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'
Image:step8.PNG
  • Goto C/C++, Additional Include Directories, and type/browse to the Bullet/src folder, in our case c:\develop\bullet-2.76\src
Image:step9.PNG
  • Repeat those steps for all configurations (Debug, Release etc), and start programming
Image:step10.PNG
  • 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:

    highlight: Unknown source file extension "dos".

You need to specify a language like this: <source lang="html">...</source>

Supported languages for syntax highlighting:

4gl, a4c, abp, ada, agda, ampl, amtrix, applescript, arc, arm, as, asm, asp, aspect, au3, avenue, awk, bat, bb, bib, bms, boo, c, cb, cfc, clipper, clp, cob, cs, css, d, diff, dot, dylan, e, erl, euphoria, exp, f77, f90, flx, frink, haskell, hcl, httpd, icn, idl, ini, inp, io, j, java, js, jsp, lbn, ldif, lgt, lisp, lotos, ls, lsl, lua, ly, m, make, mel, mib, miranda, ml, mo, mod3, mpl, ms, mssql, n, nas, nice, nsi, nut, oberon, objc, octave, oorexx, os, pas, php, pike, pl, pl1, pov, pro, progress, ps, ps1, psl, py, pyx, q, qu, r, rb, rexx, rnc, s, sas, sc, scala, scilab, sh, sma, smalltalk, sml, snobol, spec, spn, sql, sybase, tcl, tcsh, test_re, tex, ttcn3, txt, vb, verilog, vhd, xml, xpp, y

  • 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:
Image:newxcodeproject.png
  • put it in next to bullet-2.x, in the develop folder:

Image:developfolder.png

  • Open the main.cpp file and add #include "btBulletDynamicsCommon.h":

Image:addcommoninclude.png

  • Edit the project settings for All Configurations

Image:editxcodeprojectsettings.png

  • Add the bullet-2.x/src folder:

Image:addbulletsrcinclude.png

Image:addbulletsrcinclude1.png

  • Now build the project:

Image:buildxcode.png /<center>

From here, continue to the Hello World tutorial.
Views
Personal tools
Navigation
Toolbox