title: Can't build against functions in system library
body: <p>I'm going crazy here.</p>
  
  <p>Basically, I'm trying to access some functions in a shared library located in system/lib/ on the android platform, using the NDK.</p>
  
  <p>The library I'm trying to make use of is libsonivox.so.  My main goal is to use it from a NativeActivity.  I understand this can complicate things because I would need to load this library (statically) before I load my own library which depends on it.  Therefore I am trying to get it to work through a regular Activity and JNI.  </p>
  
  <p>In the Activity I load the libraries like so:</p>
  
  <pre><code>static {
    System.loadLibrary("sonivox");
    System.loadLibrary("native-audio-jni");
  }
  </code></pre>
  
  <p>The "native-audio-jni" library is from the NDK samples, but I am modifying it in a rudimentary attempt to access the sonivox functions.</p>
  
  <p>Without any calls to libsonivox from libnative-audio-jni, everything compiles fine.
  This line from the LogCat output gives me hope:</p>
  
  <pre><code>  04-26 15:01:14.973: D/dalvikvm(691): No JNI_OnLoad found in /system/lib/libsonivox.so   
    0x412a1100, skipping init
  </code></pre>
  
  <p>So the library is loaded.</p>
  
  <p>Then I add this function to native-audio-jni.c:</p>
  
  <pre><code>void Java_jay_enn_eye_JNImidiActivity_createMidi(JNIEnv* env,
          jclass clazz)
  {
    pLibConfig = EAS_Config();
  }
  </code></pre>
  
  <p>pLibConfig is declared like this:</p>
  
  <pre><code>static const S_EAS_LIB_CONFIG* pLibConfig = NULL;
  </code></pre>
  
  <p>When that is declared, without the addition of the above function, it compiles fine.  So at least the header files are... there.</p>
  
  <p>When I plop that function into the code, this is the output of ndk-build:</p>
  
  <pre><code>  Compile thumb  : native-audio-jni &lt;= native-audio-jni.c
    SharedLibrary  : libnative-audio-jni.so
    ./obj/local/armeabi/objs/native-audio-jni/native-audio-jni.o: In function
    `Java_jay_enn_eye_JNImidiActivity_createMidi':
    /home/anthony/Documents/eclipse/JNImidi/jni/native-audio-jni.c:202: undefined   
    reference
    to `EAS_Config'
    collect2: ld returned 1 exit status
    make: *** [obj/local/armeabi/libnative-audio-jni.so] Error 1
  </code></pre>
  
  <p>I'm not sure if libnative-audio-jni just can't access libsonivox, or if I need to dlsym() or sym() link the sonivox functions to use them.  I haven't been able to try either of those since the library is found in system/lib/ and not provided by me, so I don't have a full path to provide to do that.</p>
  
  <p>Another option I am considering is grabbing libsonivox.so, copying it into a directory in the project, and changing the Android.mk so that it includes the lib as a prebuilt shared library.  I was thinking maybe the library needs to be included at compile time.  </p>
  
  <p><strong>EDIT:</strong>  Here's the Android.mk file:</p>
  
  <pre><code>LOCAL_PATH := $(call my-dir)
  
  include $(CLEAR_VARS)
  
  LOCAL_MODULE    := native-audio-jni
  LOCAL_SRC_FILES := native-audio-jni.c
  # for native audio
  LOCAL_LDLIBS    += -lOpenSLES
  # for logging
  LOCAL_LDLIBS    += -llog
  # for native asset manager
  LOCAL_LDLIBS    += -landroid
  
  include $(BUILD_SHARED_LIBRARY)
  </code></pre>
  
  <p>This must be where something isn't right.  I'd think the sonivox library <strong>would</strong> need to be present when compiling everything.  However, the library won't load no matter what changes I make to this file, which have mainly involved trying to include it as a PREBUILT_SHARED_LIBRARY or PREBUILT_STATIC_LIBRARY.  Also, the OpenSL stuff works perfectly fine.  I wish sonivox would work if I were to just include it as -lsonivox, but no.</p>