How can I build BOX2D as a static lib for the iPhone?

Member
Posts: 249
Joined: 2008.10
Post: #1
Hi friends!

I got box2d running on the iPhone, just including all files into my project.
My question is: is it possible to build box2d as a static lib for the iPhone?

I already asked this question on Box2D forums, but not reply. Can you help me? Did anyone try it?

Thanks a lot.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #2
Create a new static library target and add all the Box2D source files to that instead of your application target. Then include the static library into your main app. That's really all there is to it.

You can also make a separate project for it and include the target in your game project. XCode can build targets across projects. Though you might need to fiddle with header paths then.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 249
Joined: 2008.10
Post: #3
Skorche Wrote:Create a new static library target and add all the Box2D source files to that instead of your application target. Then include the static library into your main app. That's really all there is to it.

You can also make a separate project for it and include the target in your game project. XCode can build targets across projects. Though you might need to fiddle with header paths then.

Thanks. I thought it was not possible.
BTW, should I add to my project something like -libBox2d?
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #4
No, you add the static lib target as a dependency to your app target (so it knows to build it first), and add the static lib from the "products" folder to the list of libraries to link.

You could do it using linker flags as well, but it's usually a PITA in Xcode.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Xcode 4 Build Failure on iPhone target SparkyNZ 2 7,359 Apr 7, 2011 02:48 AM
Last Post: SparkyNZ
  Static libraries... the_wandering_monster 6 4,437 Dec 31, 2009 03:46 PM
Last Post: the_wandering_monster
  OpenGL box2d scale factor lifebythedrop 4 5,939 Nov 15, 2009 06:39 AM
Last Post: mpcarr
  Static Library kendric 9 3,531 Sep 17, 2009 11:24 AM
Last Post: kendric
  How to build my own static lib and link it to iphone game zwstudio 7 4,664 Aug 18, 2008 09:06 AM
Last Post: zwstudio