title: android ndk undefined reference to a method
body: <p>Hi Sorry for the long post  I am trying to compile some static classes namely jsmn.c,json.c and buf.c which are part of the jsmn json library I downloaded from <a href="https://github.com/alisdair/jsmn-example/downloads" rel="nofollow">https://github.com/alisdair/jsmn-example/downloads</a>.</p>
  
  <p>I am compiling  two STATIC_LIBRARIES lib1 and json_librrary.lib1 has native code which is dependent on json_library.Then I am making two libraries into a shared library containing
   <b>gnustl_static AND  lib1 </b></p>
  
  <p>My folder structure is as follows</p>
  
  <p><b>jni/lib1/ANdroid.mk</b></p>
  
  <pre><code>include $(CLEAR_VARS)
  LOCAL_MODULE := json_library
  LOCAL_SRC_FILES := /3rdParty/jsmn/json_library.a
  LOCAL_SRC_FILES := /3rdParty/jsmn/jsmn.c /3rdParty/jsmn/buf.c /3rdParty/jsmn/log.c /3rdParty/jsmn/json.c 
  LOCAL_C_INCLUDES := /3rdParty/jsmn/jsmn.h /3rdParty/jsmn/buf.h /3rdParty/jsmn/log.h /3rdParty/jsmn/json.h 
  # Optional compiler flags.
  LOCAL_LDLIBS   = -lz -lm
  LOCAL_CFLAGS   = -Wall -pedantic -std=c99 -g
  include $(BUILD_STATIC_LIBRARY)
  
    include $(CLEAR_VARS)
    # Module Name
    LOCAL_MODULE    := lib1
    LOCAL_STATIC_LIBRARIES := json_library
    ........
    .......
    ......
    include $(BUILD_STATIC_LIBRARY)
  </code></pre>
  
  <p><b>jni/Android.mk</b></p>
  
  <pre><code># Here we give our module name
  LOCAL_MODULE    := lib2
  # list the static modules included here!!!
  LOCAL_STATIC_LIBRARIES :=   gnustl_static  lib1 
  ....
  include $(BUILD_SHARED_LIBRARY)
  </code></pre>
  
  <p><b>jni/Application.mk </b></p>
  
  <pre><code>APP_MODULES   :=  lib2
  # Optimization for release
  APP_OPTM := release
  #Targets
  APP_ABI := armeabi-v7a armeabi
  </code></pre>
  
  <p>So inside the lib1 I  have class which calls a method from the json library named  <b>json_tokenise</b></p>
  
  <pre><code>#include &lt;string.h&gt;
  #include &lt;stdio.h&gt;
   #include &lt;stdlib.h&gt;
   #include &lt;jsmn/jsmn.h&gt;
  #include &lt;jsmn/json.h&gt;
  #include &lt;jsmn/buf.h&gt;
  
  jsmntok_t *tokens=json_tokenise((char *)data);
  
  typedef enum {
  START,
  WRAPPER,
  MESSAGE,
  ROUTE,
  OBJECT,
  ARRAY,
  SKIP,
  STOP
  }parse_state;
  </code></pre>
  
  <p>I am getting the following error</p>
  
  <pre><code>undefined reference to `json_tokenise(char*)'
  collect2: ld returned 1 exit status
  make: *** [obj/local/armeabi-v7a/lib2.so] Error 1
  
  **** Build Finished ****
  </code></pre>
  
  <p>When I have a look inside [obj/local/armeabi-v7a/ I can see 
  <b>libjson_library.a liblib1.a libgnustl_static.a </b> are getting generated for the armabi-v7 and it fails to generate lib2 because of the error.</p>
  
  <p>Please help or guide me where I am going wrong I have spent two days on this and I am new to NDK.</p>