3
我试图构建一个共享库,最终的交叉编译一段代码,用来引用be32toh和le32toh。如果我建立这一段代码,并创建一个可执行文件出来吧,我没有得到任何错误:交叉编译使用NDK,未定义的引用le32toh和be32toh
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= ubertooth.c ubertooth_helper.c
LOCAL_MODULE := ubertooth
LOCAL_C_INCLUDES += jni/libusb jni/libbtbb
LOCAL_SHARED_LIBRARIES := libc libusb libbtbb
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
include $(BUILD_EXECUTABLE)
这编译成功:
Compile thumb : ubertooth <= ubertooth.c
Compile thumb : ubertooth <= ubertooth_helper.c
Executable : ubertooth
Install : ubertooth => libs/armeabi/ubertooth
然而,当我试图把它做成一个共享库仅通过改变在Android.mk一行:
include $(CLEAR_VARS)
...
include $(BUILD_SHARED_LIBRARY)
我现在得到以下错误:
Compile thumb : ubertooth <= ubertooth.c
Compile thumb : ubertooth <= ubertooth_helper.c
SharedLibrary : libubertooth.so
./obj/local/armeabi/objs-debug/ubertooth/ubertooth.o: In function `stream_rx_file':
ubertooth.c:224: undefined reference to `be32toh'
./obj/local/armeabi/objs-debug/ubertooth/ubertooth.o: In function `cb_lap':
ubertooth.c:281: undefined reference to `le32toh'
./obj/local/armeabi/objs-debug/ubertooth/ubertooth.o: In function `cb_hop':
ubertooth.c:417: undefined reference to `le32toh'
./obj/local/armeabi/objs-debug/ubertooth/ubertooth.o: In function `cb_btle':
ubertooth.c:506: undefined reference to `le32toh'
collect2: ld returned 1 exit status
我不明白为什么我会在构建共享库时得到此链接错误,而不是在构建可执行文件时。而且,如果我想构建共享库,如何正确链接到我缺少的东西?
什么当你使用“ndk-build V = 1”构建一个可执行文件和共享库时,它的区别是什么?有不同的D标志吗? – wojciii 2012-07-28 17:09:06