Box2D Forums

It is currently Mon Jul 28, 2014 1:28 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Sun Nov 06, 2011 3:50 pm 
Offline

Joined: Sun Nov 06, 2011 3:40 pm
Posts: 4
language: c++
environment: xCode 4
version of Box2D: 2.2.1

I just need some idea of how to add box2d to my current project…
I've tried everything I can think of: adding the source files to my project, making a libBox2d.a file and adding that… I've also tried adding the Box2d directory to my "header search paths" but everything I do just results in header files that can't be found…

i think I'm missing something very simple. so just a simple step by step would be amazing… everything else I've found on the internet is for different versions of either Xcode or box2d and none of them work… I don't know what else to do. been pulling my hair out for days.


Top
 Profile  
 
PostPosted: Sun Nov 06, 2011 7:02 pm 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2946
I think that version of Box2D comes with an Xcode project file. You can see how that is set up.


Top
 Profile  
 
PostPosted: Sun Nov 06, 2011 9:45 pm 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1903
Location: Tokyo
It could just be that your header search paths setting is one level off... Box2D source is set up to be included as:

#include <Box2D/Box2D.h>

...so your header search path should specify the folder above where the Box2D.h file is, not the actual folder that contains it.
http://www.iforce2d.net/b2dtut/setup-ios


Top
 Profile  
 
PostPosted: Mon Nov 07, 2011 10:02 pm 
Offline

Joined: Sun Nov 06, 2011 3:40 pm
Posts: 4
Erin Catto wrote:
I think that version of Box2D comes with an Xcode project file. You can see how that is set up.

I found the Xcode project file, I just have no idea what to do with it. i mean, it runs and everything, but how does that help me exactly? how do i get the box2d library in my own project?
thanks,


Last edited by dylpickler on Mon Nov 07, 2011 10:11 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Mon Nov 07, 2011 10:39 pm 
Offline

Joined: Sun Nov 06, 2011 3:40 pm
Posts: 4
irresistible force wrote:
It could just be that your header search paths setting is one level off... Box2D source is set up to be included as:

#include <Box2D/Box2D.h>

...so your header search path should specify the folder above where the Box2D.h file is, not the actual folder that contains it.
http://www.iforce2d.net/b2dtut/setup-ios


ok. I changed my #include to the one you said above and changed my header search path from "Box2D" to "./". the code compiles now and no longer gives me all those linker errors! woot! :D. but now xCode is giving me a "Apple Mach-O Linker (Id) Warning" it says "ld: warning: directory not found for option '-L/Users/dylpickler/Programs/The Deep Project/The Deep Project/Box2D'"

I also tried "../" as my header search path and got the same result then I tried changing my include back to #include "Box2D.h" and it still runs, it just gives that warning do you have any idea what that warning means? i seem to be able to access box2d functions and use them now, so I'm not sure what its complaining about. thanks so much


Top
 Profile  
 
PostPosted: Mon Nov 07, 2011 10:50 pm 
Offline

Joined: Sun Nov 06, 2011 3:40 pm
Posts: 4
nevermind… turns out the error was left over from one of my previous attempts to fix this issue.
thanks for all your help and the quick replies folks.

if anyone else is reading this and trying to learn from my mistakes and they want a step by step, heres what I ended up doing: I put the Box2D folder (the one with the Box2D.h file and all the source files in sub folders) not in the folder with all my source files for my project, but the folder above that, the one with my Xcode project file in it. Inside Xcode I clicked "Add files to project" and chose that same box2d folder. then under project build settings, I changed "always search user paths" to yes and I double clicked on "user header search paths" and put in
Code:
./
as my path and checked the recursive box.


Top
 Profile  
 
PostPosted: Thu Nov 24, 2011 7:22 pm 
Offline

Joined: Thu Nov 24, 2011 7:09 pm
Posts: 1
I've found that if you create a project using a cocos2d template and you include the box2d source, the build search paths in 'Build Settings' are filled in with 'YES' for 'Always Search Users Paths' and 'User Header Search Paths' always contain your project directory name and /libs... Example: If your projects directory name is 'MyBox2D' then the 'User Header Search Paths should read: 'MyBox2D/libs'. I've found that this works every time for me when I include cocos2D Box2D source in XCode 4.2 using iOS 5. 8-)


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

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 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