title: undefined references linking a pre-built shared library in Android with NDK
body: <p>I have a pre-built shared libray called "tshark.so" that I am attempting to link whenever I build another shared library (libwireshark_helper.so). libtshark.so is in $(LOCAL_PATH).  Here is my Android.mk</p>
  
  <pre><code>LOCAL_PATH:= $(call my-dir)                                                                                                                                                                                                                                                        
  include $(CLEAR_VARS)                                                                                                                                                                                                                                                              
  NDK_MODULE_PATH := $(LOCAL_PATH)                                                                                                                                                                                                                                                   
  LOCAL_SRC_FILES:= wireshark_helper.c                                                                                                                                                                                                                                
  LOCAL_MODULE := libwireshark_helper                                                                                                                                                                                                                                                
  LOCAL_PREBUILT_LIBS := libtshark.so                                                                                                                                                                                                                                                
  LOCAL_C_INCLUDES += jni/libusb-compat/libusb jni/wispy jni/libpcap jni/libwireshark jni/libglib jni/libglib/glib jni/libglib/android jni/libwireshark/epan jni/libwireshark/epan/dissectors                                                                                        
  LOCAL_SHARED_LIBRARIES := libc libusb libusb-compat libwispy libpcap libglib-2.0 libgmodule-2.0 libnl libtshark                                                                                                                                                                    
  LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -L$(LOCAL_PATH) -llog -ltshark -lgcc -lz                                                                                                                                                                                                      
  include $(BUILD_SHARED_LIBRARY)
  </code></pre>
  
  <p>For example, the 'tshark' library contains the method 'tshark_log_handler' which is shown here:</p>
  
  <pre><code>$ arm-eabi-nm libtshark.so | grep tshark_log_handler
  005d298c t tshark_log_handler
  </code></pre>
  
  <p>However, when I attempt to build, I get the error:</p>
  
  <pre><code>SharedLibrary  : libwireshark_helper.so
  /Users/gnychis/Documents/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-g++ -Wl,-soname,libwireshark_helper.so -shared --sysroot=/Users/gnychis/Documents/android-ndk-r5b/platforms/android-9/arch-arm   /Users/gnychis/Documents/workspace/CoexiSyst/obj/local/armeabi/objs-debug/wireshark_helper/wireshark_helper.o    /Users/gnychis/Documents/workspace/CoexiSyst/obj/local/armeabi/libusb.so /Users/gnychis/Documents/workspace/CoexiSyst/obj/local/armeabi/libusb-compat.so /Users/gnychis/Documents/workspace/CoexiSyst/obj/local/armeabi/libwispy.so /Users/gnychis/Documents/workspace/CoexiSyst/obj/local/armeabi/libpcap.so /Users/gnychis/Documents/workspace/CoexiSyst/obj/local/armeabi/libglib-2.0.so /Users/gnychis/Documents/workspace/CoexiSyst/obj/local/armeabi/libgmodule-2.0.so /Users/gnychis/Documents/workspace/CoexiSyst/obj/local/armeabi/libnl.so /Users/gnychis/Documents/android-ndk-r5b/platforms/android-9/arch-arm/usr/lib/libc.so /Users/gnychis/Documents/android-ndk-r5b/platforms/android-9/arch-arm/usr/lib/libstdc++.so /Users/gnychis/Documents/android-ndk-r5b/platforms/android-9/arch-arm/usr/lib/libm.so   -Wl,--no-undefined -Wl,-z,noexecstack -L/Users/gnychis/Documents/android-ndk-r5b/platforms/android-9/arch-arm/usr/lib -L/Users/gnychis/Documents/android-ndk-r5b/platforms/android-9/arch-arm/usr/lib -L/Users/gnychis/Documents/workspace/CoexiSyst/jni/libwireshark -llog -ltshark -lgcc -lz -Wl,-rpath-link=/Users/gnychis/Documents/android-ndk-r5b/platforms/android-9/arch-arm/usr/lib -lsupc++ -o /Users/gnychis/Documents/workspace/CoexiSyst/obj/local/armeabi/libwireshark_helper.so
  /Users/gnychis/Documents/workspace/CoexiSyst/obj/local/armeabi/objs-debug/wireshark_helper/wireshark_helper.o: In function `Java_com_gnychis_coexisyst_CoexiSyst_wiresharkHello':
  /Users/gnychis/Documents/workspace/CoexiSyst/jni/libwireshark/wireshark_helper.c:124: undefined reference to `tshark_log_handler'
  </code></pre>
  
  <p>Why should I be getting an undefined reference?  It is in my shared library, and there is a "-ltshark" in my gcc command.  I do not get an error that it cannot find this library.</p>