title: WARNING: .../Android.mk: non-system libraries in linker flags
body: <p>I'm getting this warning while running <code>$ANDROID_NDK_ROOT/ndk-build</code>. The <code>Android.mk</code> is below.</p>
  
  <pre><code>$ $ANDROID_NDK_ROOT/ndk-build 
  
  WARNING:/Users/jwalton/Android-CryptoPP/jni/Android.mk:prng:
      non-system libraries in linker flags: -lcryptopp -lstlport_shared    
      This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES    
      or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
      current module
  ...
  </code></pre>
  
  <p>However, when I follow the instructions and remove <code>-lcryptopp -lstlport_shared</code> from <code>LOCAL_LDLIBS</code>, then I get link errors related to symbols from <code>libstlport_shared.so</code>. A sample of the errors are shown below after the <code>Android.mk</code> file.</p>
  
  <p>How, exactly, does <code>ndk-build</code> want <code>Android.mk</code> set up?</p>
  
  <p>Why do I have to add <code>$(STLPORT_INCL)</code> to <code>LOCAL_C_INCLUDES</code>, and <code>$(STLPORT_LIB)</code> to <code>LOCAL_LDFLAGS</code>? Why does <code>APP_STL := stlport_shared</code> <em>not</em> setup the STL correctly out of the box?</p>
  
  <hr>
  
  <pre><code>LOCAL_PATH := $(call my-dir)
  
  include $(CLEAR_VARS)
  
  TARGET_ARCH_ABI := armeabi
  TARGET_ABI      := android-9-armeabi
  
  CRYPTOPP_INCL   := /usr/local/cryptopp-android-9/include
  CRYPTOPP_LIB    := /usr/local/cryptopp-android-9/lib
  
  STLPORT_INCL    := /opt/android-ndk-r9/sources/cxx-stl/stlport/stlport
  STLPORT_LIB     := /opt/android-ndk-r9/sources/cxx-stl/stlport/libs/armeabi
  
  APP_STL         := stlport_shared
  APP_MODULES     := stlport_shared cryptopp
  
  LOCAL_CPP_FEATURES := rtti exceptions
  
  LOCAL_C_INCLUDES := $(CRYPTOPP_INCL) $(CRYPTOPP_INCL)/cryptopp $(STLPORT_INCL)
  
  LOCAL_LDFLAGS  := -L $(CRYPTOPP_LIB) -L $(STLPORT_LIB)
  LOCAL_LDLIBS   := -lcryptopp -lstlport_shared -llog -landroid
  # LOCAL_LDLIBS   := -llog -landroid
  # LOCAL_SHARED_LIBRARIES := -lcryptopp -lstlport_shared
  
  LOCAL_MODULE    := prng
  LOCAL_SRC_FILES := libprng.cpp
  
  include $(BUILD_SHARED_LIBRARY)
  </code></pre>
  
  <hr>
  
  <p>Here is a sample of the error when trying to follow the advice by removing my local libraries from <code>LOCAL_LDLIBS</code>:</p>
  
  <pre><code>$ $ANDROID_NDK_ROOT/ndk-build 
  Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 9 in /Users/jwalton/Android-CryptoPP/AndroidManifest.xml    
  Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
  Gdbsetup       : libs/armeabi/gdb.setup
  Compile++ thumb  : prng &lt;= libprng.cpp
  SharedLibrary  : libprng.so
  /opt/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /Users/jwalton/Android-CryptoPP/obj/local/armeabi/objs-debug/prng/libprng.o: in function std::__node_alloc::allocate(unsigned int&amp;):/opt/android-ndk-r9/sources/cxx-stl/stlport/stlport/stl/_alloc.h:158: error: undefined reference to 'std::__node_alloc::_M_allocate(unsigned int&amp;)'
  /opt/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /Users/jwalton/Android-CryptoPP/obj/local/armeabi/objs-debug/prng/libprng.o: in function std::__node_alloc::deallocate(void*, unsigned int):/opt/android-ndk-r9/sources/cxx-stl/stlport/stlport/stl/_alloc.h:161: error: undefined reference to 'std::__node_alloc::_M_deallocate(void*, unsigned int)'
  /opt/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /Users/jwalton/Android-CryptoPP/obj/local/armeabi/objs-debug/prng/libprng.o: in function std::ios_base::_M_check_exception_mask():/opt/android-ndk-r9/sources/cxx-stl/stlport/stlport/stl/_ios_base.h:193: error: undefined reference to 'std::ios_base::_M_throw_failure()'
  </code></pre>
  
  <p>...</p>