Page 1 of 5

How To Use Chipmunk in Visual C++ '08 for your own Projects

Posted: Sun Feb 10, 2008 2:29 pm
by theanzelm
How to use the Chipmunk Physics Engine for your own Projects in Visual C++ 2008
Because it took me 3 hours to find out... I made this Tutorial!

1.Get Chipmunk and glext.h

- Download Chipmunk Physics here: http://files.slembcke.net/chipmunk/rele ... Latest.tgz

- Extract the File (with WinRar for example)

- In the extracted Folder go to:

"<extracted Folder>/Chipmunk-X.X.X/MSVCSolution/"

- Download this file: (it is needed for the demos): http://www.opengl.org/registry/api/glext.h (right click/save as)

- Put it into "<extracted Folder>/Chipmunk-X.X.X/MSVCSolution/"

2. Compile Chipmunk

- Go into "<extracted Folder>/Chipmunk-X.X.X/MSVCSolution/"

- Open "Chipmunk4MSVC2k3.sln"

- Now VC++ will ask you if you want to convert the solution

- Click "Next"

- Click "Next" again

- Click "Finish"

- Uncheck "Show the conversion log..."

- Click Close

- Open main.c

Image

- Edit two lines as shown in the image:

Image

- Now press F5, now everything should compile fine. (If not tell me!)

- Now the Chipmunk Demo Application should start. Close it (or, first play around a bit and be impressed).

- You successfully built Chipmunk!

3. Use it in your own Project

- Open your project in VC++

- to your main application file (normally <project name>.cpp), add:

Code: Select all

#include "chipmunk.h"
- now in the menu open "Tools/Options..."

- in the Options Window go to "Projects and solutions/VC++ Directories"

- select "Include Files"

- add a directory

- enter: "<extracted Folder>/Chipmunk-X.X.X/src"

Image

- do the same as above, first select "Library Files"

- add a directory

- enter: "<extracted Folder>/Chipmunk-X.X.X/MSVCSolution/Chipmunk4MSVC2k3/Release"

- now right-click your project in the Solution Explorer and click on "Properties"

Image

- In the Properties Window go to "Linker/Input"

- Add additional Dependencies:

Image

- Enter the Following lines:

Code: Select all

chipmunk.obj
cpArbiter.obj
cpArray.obj
cpBB.obj
cpBody.obj
cpCollision.obj
cpHashSet.obj
cpJoint.obj
cpPolyShape.obj
cpShape.obj
cpSpace.obj
cpSpaceHash.obj
cpVect.obj
Image

- Press "OK"

- Press "OK" again

- Press F5

- Your application should now compile fine and you can use Chipmunk like you want.
(see Documentation)

I hope everything worked well, and you can enjoy now the Chipmunk Physics Engine.

Anselm

If anything doesn't work please tell me!

Re: How To Use Chipmunk in Visual C++ '08 for your own Projects

Posted: Sun Feb 10, 2008 9:07 pm
by slembcke
Thanks. I made it sticky.

Re: How To Use Chipmunk in Visual C++ '08 for your own Projects

Posted: Tue Feb 12, 2008 6:48 am
by rogue72
hi

(using msvc express c++ 2008 , xp sp2)

Thanks for the tutorial, being new to both msvc & chipmunk, i was not finding it easy :cry:
Following the tutorial here i can compile and run a project that doesnt do much other then execute
cpInitChipmunk(); and then just sits in a loop.

However during compile i get these compiler warnings, and wondered if i need to enable/disable
any further settings.

cpSpace.obj : warning LNK4217: locally defined symbol _free imported in function _cpSpaceInit
cpSpaceHash.obj : warning LNK4049: locally defined symbol _free imported
cpHashSet.obj : warning LNK4049: locally defined symbol _free imported
cpJoint.obj : warning LNK4049: locally defined symbol _free imported
cpPolyShape.obj : warning LNK4049: locally defined symbol _free imported
cpShape.obj : warning LNK4049: locally defined symbol _free imported
chipmunk.obj : warning LNK4217: locally defined symbol _free imported in function _cpMomentForPoly
cpArbiter.obj : warning LNK4049: locally defined symbol _free imported
cpArray.obj : warning LNK4049: locally defined symbol _free imported
cpBody.obj : warning LNK4049: locally defined symbol _free imported
cpSpaceHash.obj : warning LNK4049: locally defined symbol _calloc imported
cpHashSet.obj : warning LNK4049: locally defined symbol _calloc imported
cpPolyShape.obj : warning LNK4049: locally defined symbol _calloc imported
cpShape.obj : warning LNK4049: locally defined symbol _calloc imported
cpSpace.obj : warning LNK4049: locally defined symbol _calloc imported
chipmunk.obj : warning LNK4217: locally defined symbol _calloc imported in function _cpMomentForPoly
cpArbiter.obj : warning LNK4049: locally defined symbol _calloc imported
cpArray.obj : warning LNK4049: locally defined symbol _calloc imported
cpCollision.obj : warning LNK4049: locally defined symbol _calloc imported
cpJoint.obj : warning LNK4049: locally defined symbol _malloc imported
cpSpace.obj : warning LNK4049: locally defined symbol _malloc imported
cpSpaceHash.obj : warning LNK4049: locally defined symbol _malloc imported
cpArray.obj : warning LNK4217: locally defined symbol _malloc imported in function _cpArrayInit
cpBody.obj : warning LNK4049: locally defined symbol _malloc imported
cpCollision.obj : warning LNK4049: locally defined symbol _malloc imported
cpHashSet.obj : warning LNK4049: locally defined symbol _malloc imported
cpArray.obj : warning LNK4217: locally defined symbol _realloc imported in function _cpArrayPush
cpCollision.obj : warning LNK4049: locally defined symbol _realloc imported
cpVect.obj : warning LNK4217: locally defined symbol _sprintf imported in function _cpvstr


Regards
Mark

Re: How To Use Chipmunk in Visual C++ '08 for your own Projects

Posted: Tue Feb 12, 2008 7:36 am
by theanzelm
What didn't you find easy? MSVC & Chipmunk or the tutorial?

I didn't try much more myself, but I will soon try more stuff.

Strange. I don't get those warnings and I have the same environment as you and use all the default settings. But if everything works you can ignore them.
Where or How did you create your own Project?

Re: How To Use Chipmunk in Visual C++ '08 for your own Projects

Posted: Thu Feb 14, 2008 1:17 am
by Zeus3rd
I found that with the latest version of Chipmunk (Mid-Feburary 2008) I needed to use "MSVCSolution\Chipmunk4MSVC2k3\Release" in the Library file directory list rather than "Chipmunk4MSVC2k3". I don't know if this was my fault or not but it made it run :D

Excellent straight forward Tutorial btw.

Re: How To Use Chipmunk in Visual C++ '08 for your own Projects

Posted: Mon Feb 18, 2008 12:36 pm
by theanzelm
Zeus3rd wrote:I found that with the latest version of Chipmunk (Mid-Feburary 2008) I needed to use "MSVCSolution\Chipmunk4MSVC2k3\Release" in the Library file directory list rather than "Chipmunk4MSVC2k3". I don't know if this was my fault or not but it made it run :D
Thank you, of course it has to be with /Release.

Re: How To Use Chipmunk in Visual C++ '08 for your own Projects

Posted: Fri Feb 29, 2008 2:58 am
by parasight
I built both a static libarary and a DLL from the chipmunk source with Visual Studio '05. I can provide code & solution if there is any interest. I also built the ruby bindings without mingw or cygwin. I had to tweak the source code a little bit though. Nothing fancy but it seems there might be some interest.

Peace

Re: How To Use Chipmunk in Visual C++ '08 for your own Projects

Posted: Tue Mar 04, 2008 2:22 am
by aisman
parasight wrote:I built both a static libarary and a DLL from the chipmunk source with Visual Studio '05. I can provide code & solution if there is any interest. Peace
Yes please.

Re: How To Use Chipmunk in Visual C++ '08 for your own Projects

Posted: Tue Mar 04, 2008 2:20 pm
by parasight

Re: How To Use Chipmunk in Visual C++ '08 for your own Projects

Posted: Wed Mar 05, 2008 1:15 am
by aisman
@parasight,
Thanks... but have you also the static library project for me?