title: Include prebuilt static library
body: <p>I created a static C++ library for testing. It only defines a class, <code>MyLibrary</code>, and the constructor <code>MyLibrary::MyLibrary()</code>. I built it in qtcreator, and got a <code>libMyLibrary.a</code> file, which is a prebuilt static library.</p>
  
  <p>I would like to use this library in an Android project (using the NDK). In a working NDK test project, I therefore added a folder called <code>inc</code> at the same level as <code>jni</code>, in which I put <code>libMyLibrary.a</code> and its corresponding header <code>mylibrary.h</code>.</p>
  
  <p>My <code>Android.mk</code> is as follows:</p>
  
  <pre><code>LOCAL_PATH := $(call my-dir)
  
  include $(CLEAR_VARS)
  
  LOCAL_MODULE    := MyLibrary
  LOCAL_SRC_FILES := ../inc/libMyLibrary.a
  
  include $(PREBUILT_STATIC_LIBRARY)
  
  include $(CLEAR_VARS)
  LOCAL_MODULE    := helloJNI
  LOCAL_SRC_FILES := mainActivity.cpp
  
  LOCAL_C_INCLUDES += inc
  LOCAL_STATIC_LIBRARIES := MyLibrary
  
  LOCAL_LDLIBS    := -llog
  include $(BUILD_SHARED_LIBRARY)
  </code></pre>
  
  <p><strong>The <code>ndk-build</code> command compiles without any error.</strong> But my static library is apparently not linked (i.e. it does not appear in <code>obj/local/armeabi/objs</code>).</p>
  
  <p>I have tried to include it in my <code>mainActivity.cpp</code> file, but even though the header (<code>mylibrary.h</code>) is found, the library is not and I cannot create an object as in:</p>
  
  <pre><code>MyLibrary test = MyLibrary();
  </code></pre>
  
  <p>What am I doing wrong? I have read tens of similar questions on StackOverflow, but I still don't get it.</p>