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

Official forum for the Chipmunk2D Physics Library.
theanzelm
Posts: 17
Joined: Sun Jan 06, 2008 7:06 am
Contact:

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

Post 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!
Last edited by theanzelm on Mon Feb 18, 2008 12:37 pm, edited 1 time in total.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

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

Post by slembcke »

Thanks. I made it sticky.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
rogue72
Posts: 1
Joined: Tue Feb 12, 2008 6:27 am
Contact:

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

Post 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
theanzelm
Posts: 17
Joined: Sun Jan 06, 2008 7:06 am
Contact:

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

Post 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?
Zeus3rd
Posts: 1
Joined: Thu Feb 14, 2008 1:14 am
Contact:

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

Post 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.
theanzelm
Posts: 17
Joined: Sun Jan 06, 2008 7:06 am
Contact:

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

Post 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.
parasight
Posts: 4
Joined: Fri Feb 29, 2008 2:20 am
Contact:

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

Post 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
aisman
Posts: 145
Joined: Tue Mar 04, 2008 2:21 am
Contact:

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

Post 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.
Chipmunk4PB: The fastest way to write games together with PureBasic and the Chipmunk physics engine.
aisman
Posts: 145
Joined: Tue Mar 04, 2008 2:21 am
Contact:

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

Post by aisman »

@parasight,
Thanks... but have you also the static library project for me?
Chipmunk4PB: The fastest way to write games together with PureBasic and the Chipmunk physics engine.
Post Reply

Who is online

Users browsing this forum: Heise IT-Markt [Crawler] and 16 guests