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

Official forum for the Chipmunk2D Physics Library.

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

Postby theanzelm » Sun Feb 10, 2008 2:29 pm

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

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

Postby slembcke » Sun Feb 10, 2008 9:07 pm

Thanks. I made it sticky.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

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

Postby rogue72 » Tue Feb 12, 2008 6:48 am

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
rogue72
 
Posts: 1
Joined: Tue Feb 12, 2008 6:27 am

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

Postby theanzelm » Tue Feb 12, 2008 7:36 am

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

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

Postby Zeus3rd » Thu Feb 14, 2008 1:17 am

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

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

Postby theanzelm » Mon Feb 18, 2008 12:36 pm

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

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

Postby parasight » Fri Feb 29, 2008 2:58 am

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

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

Postby aisman » Tue Mar 04, 2008 2:22 am

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.
User avatar
aisman
 
Posts: 143
Joined: Tue Mar 04, 2008 2:21 am


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

Postby aisman » Wed Mar 05, 2008 1:15 am

@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.
User avatar
aisman
 
Posts: 143
Joined: Tue Mar 04, 2008 2:21 am

Next

Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest