I'm writing a static library for the iPhone and I'm wondering if what I'm doing is recommended or if I should take a different approach.
The static library I'm writing is dependant on libxml2. libxml2 has a dynamic library (dylib) and a static library (a). I've tried two approaches.
Approach one - When I attempt to link against the static library by adding "-lxml2" to "Other linker flags" the build fails with the following message:
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool: file: -lxml2 is not an object file (not allowed in a library)
Approach two - I can successfully link against the dynamic library from my static library but I'm not sure if this is allowed (or the proper approach) on the iPhone. Even though I'm building a static library, does Apple allow static libraries that link against dynamic libraries? I'm still learning about static libraries, but from my understanding the code from the dylib would be combined with my code to make one library, thus linking against the dylib shouldn't be an issue.
To summarize:
- mylibrary.a -> libxml2.a [Doesn't work]
- mylibrary.a -> libxml2.dylib [Builds, but is this correct and acceptable?]