title: Android: How to link my own static libraries correctly?
body: <p>I have an Android project written in C++ and have a problem in linking phase. The code is put in some static libraries which should be linked together.</p>
  
  <p>I have found a lot of questions and answers on the net about this topic and most of them suggest to put my libraries to <code>LOCAL_STATIC_LIBRARIES</code> in the Android.mk file. But, if I do this, I found the content of <code>LOCAL_STATIC_LIBRARIES</code> is simply ignored: my libraries are not linked, and adding any dummy text here does not generate any error or warning message.</p>
  
  <p>I tried it this way:</p>
  
  <pre><code>LOCAL_STATIC_LIBRARIES := MyLib.a
  </code></pre>
  
  <p>or with full path:</p>
  
  <pre><code>LOCAL_STATIC_LIBRARIES := $(LOCAL_PATH)/MyLib.a
  </code></pre>
  
  <p>none of them worked.</p>
  
  <p>If I put my static libraries to <code>LOCAL_LDLIBS</code> then it is linked, but I got a warning message about non-system libraries are used, and probably the build will be wrong.</p>
  
  <p>The content of my Android.mk file is:</p>
  
  <pre><code>LOCAL_LDLIBS := $(LOCAL_PATH)/MyLib.a ...
  </code></pre>
  
  <p>and I got this message:</p>
  
  <pre><code>Android NDK: WARNING:jni/Android.mk:myapp: non-system libraries in linker flags: jni/MyLib.a    
  Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES    
  Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the    
  Android NDK:     current module    
  </code></pre>
  
  <p>I could not find how to use <code>LOCAL_STATIC_LIBRARIES</code> right way, please help me!</p>
  
  <p>I have android-ndk-r9 and android-sdk_r22.2.1 on a OpenSuSE x86 and using target=android-18</p>