Box2D Forums

It is currently Thu May 23, 2013 2:56 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed Apr 18, 2012 3:28 pm 
Offline

Joined: Wed Apr 18, 2012 3:13 pm
Posts: 6
Hello there. I've been trying to to implement Box2D with my C++/SFML project but I'm not sure how to do this. It's always such a hassle for me to link libraries because I don't quite understand it. I downloaded Box2D and unzipped it to my desktop. I read the building text file which says "The Build folder contains custom made project files for Visual Studio 2010 and XCode4.". Now I'm assuming I don't have to use CMake at all and everything that I need is here? I tried the HelloWorld project and it worked correctly and I checked out the project settings. It only links to the Box2D.lib if I'm correct. I tried to copy this so all I really did was put that Box2D.lib file in my project's directory where all my cpp files are. I'm only interested in the release version.


If someone could help me step by step then that would be great.

EDIT: I also copied the source(from Box2D_v2.2.1>Box2D...I hope that is right) into my project.

EDIT2: I removed that for now because I can't compile .h files so I did something wrong


Top
 Profile  
 
PostPosted: Thu Apr 19, 2012 11:23 am 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
The build files are provided mainly as a convenience for running the testbed. I recommend that you manually create a project file and add the main Box2D source to that project. Then setup the project dependencies so your application depends on the Box2D project.


Top
 Profile  
 
PostPosted: Thu Apr 19, 2012 3:29 pm 
Offline

Joined: Wed Apr 18, 2012 3:13 pm
Posts: 6
Thanks, I did that and everything was set up properly...well almost.

I can create gravity, but when I try to create a world I get a bunch of
Code:
Error   18   error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in CollisionLayer.obj   C:\Users\Mathew\Documents\Visual Studio 2010\Projects\ColonyGame\ColonyGame\Box2D.lib(b2World.obj)


and

Code:
Error   62   error LNK1319: 42 mismatches detected   C:\Users\Mathew\Documents\Visual Studio 2010\Projects\ColonyGame\Release\ColonyGame.exe


Now I've run into a problem like this when I was setting up SFML. Defining '_ITERATOR_DEBUG_LEVEL' as a constant 0 fixed it but broke something else. In the end I just put my project in to release and it works. But I'm still getting this error in release mode.

EDIT: Wait, I may have built the debug version by accident. I will check it now.


Top
 Profile  
 
PostPosted: Thu Apr 19, 2012 7:32 pm 
Offline

Joined: Wed Apr 18, 2012 3:13 pm
Posts: 6
SOLVED!

I was right :) I built the release binaries and used those and it works like a charm now. Thanks for the help, Erin.


Top
 Profile  
 
PostPosted: Fri Nov 16, 2012 5:51 pm 
Offline

Joined: Fri Nov 16, 2012 5:40 pm
Posts: 2
Erin Catto wrote:
The build files are provided mainly as a convenience for running the testbed. I recommend that you manually create a project file and add the main Box2D source to that project. Then setup the project dependencies so your application depends on the Box2D project.


I'm having trouble myself, this is exactly what I want/am trying to do, but it causes me to have to change "#include <Box2D/Box2D.h>" to "#include "Box2D/Box2D.h" ", everywhere. I don't want to change the box2d sources. isn't there a step by step guide out there for using this with Visual C++ 2010 Express? I don't want to reuse the hello world project either because I don't want my project to be called Hello World. I can't quite figure out how to include the .lib either.


Top
 Profile  
 
PostPosted: Fri Nov 16, 2012 6:07 pm 
Offline

Joined: Fri Nov 16, 2012 5:40 pm
Posts: 2
Venevus wrote:
Erin Catto wrote:
The build files are provided mainly as a convenience for running the testbed. I recommend that you manually create a project file and add the main Box2D source to that project. Then setup the project dependencies so your application depends on the Box2D project.


I'm having trouble myself, this is exactly what I want/am trying to do, but it causes me to have to change "#include <Box2D/Box2D.h>" to "#include "Box2D/Box2D.h" ", everywhere. I don't want to change the box2d sources. isn't there a step by step guide out there for using this with Visual C++ 2010 Express? I don't want to reuse the hello world project either because I don't want my project to be called Hello World. I can't quite figure out how to include the .lib either.


oh boy, this is one thing (i'm probably missing another step, i'll get to that in a moment); in your project in visual cpp, right click, click "References", under "Configuration Properties -> C/C++ -> General", in the "Additional Include Directories" field, make sure you have added your box2D folder (same as it appears in the given Hello World program).

Also, I add the project "Box2D" to my dependencies for my project, but I don't yet know if that's necessary or not.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: TBAPb23 and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group