title: Proper way to link against libraries from libraries for the iPhone/CocoaTouch
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>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:</p>
  
  <pre><code>/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool: file: -lxml2 is not an object file (not allowed in a library)
  </code></pre>
  
  <p>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.</p>
  
  <p>To summarize:</p>
  
  <ul>
  <li>mylibrary.a -> libxml2.a [Doesn't work] </li>
  <li>mylibrary.a -> libxml2.dylib [Builds, but is this correct and acceptable?]</li>
  </ul>