Duplicate symbol: Include static lib A in static lib B, also include lib A and B in XCode Project

I've been trying to build up a set of reusable libraries for app development, but I'm starting to run into a problem.

One of my static libs is a set of general use methods (categories on Objective-C Foundation classes to improve their usability) which I tend to use in every project. (We'll call it Lib A... i.e. XCode project A produces libProjectA.a)

Then I have other static libs, things that contain specialized code for math, etc. (We'll call it Lib B.) Lib B links to Lib A because it needs to use some of that general functionality. (i.e. XCode project B links with libProjectA.a and produces libProjectB.a)

In my XCode project, I want to include and depend on Lib A because it has my general use stuff that I use all the time. I also want to include and depend on Lib B because I need that specialized math functionality. (i.e. my app Project wants to link with libProjectA.a and libProjectB.a)

However, when I try to build my XCode project I get errors for duplicate symbols, because the symbols that are defined in Lib A are also defined in Lib B.

ld: duplicate symbol _OBJC_METACLASS_$_Foo in /Users/kenny/xcode_build/Release-iphonesimulator/lib_ApplicationCore.a(Foo.o) and /Users/kenny/xcode_build/Release-iphonesimulator/lib_SpecializedMath.a(Foo.o)

How can I get around this problem? I want to develop reusable libraries to speed my app development as well as increase stability through tested/refined code. Am I approaching this from the wrong perspective? I'm developing for iOS so I can't use dylibs, they must be static.

How can I include these libraries in my project when they are interdependent upon each other and avoid the duplicate symbols?

11
задан Kenny Wyland 9 March 2011 в 22:46
поделиться