开发者

undefined references linking a pre-built shared library in Android with NDK

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

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/libw开发者_如何学运维ireshark 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)

For example, the 'tshark' library contains the method 'tshark_log_handler' which is shown here:

$ arm-eabi-nm libtshark.so | grep tshark_log_handler
005d298c t tshark_log_handler

However, when I attempt to build, I get the error:

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'

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.


The symbol type "t" from nm means that the symbol is in the library but it is not global. Global functions are shown as symbol type "T". In other words the function was declared with the "static" keyword, and you can't use it in your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜