title: How to correctly resolve android ndk shared library dependencies in final apk
body: <p>Assume I have a MVS solution with 3 projects. 2 of them are libraries and the third one is an exe. A.lib, B.lib, C.exe. A depends on B and C includes A and B, and we are all happy, the linker finds everything A needs from B when we include both in C.</p>
  
  <p>I'm trying to replicate this with android ndk (using ndk-build), so the easiest way seemed to create 2 shared libs (A.so and B.so) and include them on a third C.so that then gets packed as a native activity in C.apk.</p>
  
  <p>Apparently A.so won't build unless I include B.so in it's makefile. So instead of having</p>
  
  <pre><code>A.lib---&gt; C.exe
  B.lib--/
  </code></pre>
  
  <p>As I had in windows, I now need to have:</p>
  
  <pre><code>B.so --&gt; A.so --&gt; C.so
  </code></pre>
  
  <p>This gets pretty confusing as more libraries are added, because instead of resolving the linker symbols when adding the libs to the final apk, they need to be resolved in each lib.
  This behavior can be bypassed by using:</p>
  
  <pre><code>LOCAL_ALLOW_UNDEFINED_SYMBOLS=true
  </code></pre>
  
  <p>in the Android.mk of the libraries, but then when loading them into the application with </p>
  
  <pre><code>static 
  {
   System.loadLibrary("B");
   System.loadLibrary("A");
  }
  </code></pre>
  
  <p>it will fail at runtime saying A can't find some symbols (that are defined in B).</p>
  
  <p>Is there a "correct" way of getting the individual libs to build allowing for undefined symbols and then making sure they find them when I include them all in the final project?</p>