我想为版本 4.0.3 构建库 .so 但我无法这样做。我觉得这些问题是由于我的 .mk 文件没有与库链接而引起的。
Android.mk 文件
Binder.cpp \
BpBinder.cpp \
CursorWindow.cpp \
IInterface.cpp \
IMemory.cpp \
IPCThreadState.cpp \
IPermissionController.cpp \
IServiceManager.cpp \
MemoryDealer.cpp \
MemoryBase.cpp \
MemoryHeapBase.cpp \
MemoryHeapPmem.cpp \
Parcel.cpp \
PermissionCache.cpp \
ProcessState.cpp \
Static.cpp
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS += -lpthread
LOCAL_MODULE := libbinder1
LOCAL_SHARED_LIBRARIES := liblog libcutils libutils
LOCAL_SRC_FILES := $(sources)
include $(BUILD_SHARED_LIBRARY)
#include $(CLEAR_VARS)
#LOCAL_CFLAGS += -DHAVE_PTHREADS
#LOCAL_LDLIBS += -lpthread
#LOCAL_MODULE := libbinder
#LOCAL_SRC_FILES := $(sources)
#include $(BUILD_STATIC_LIBRARY)
该文件为我构建静态即 .a 文件,但在构建共享库时显示以下错误。
[armeabi] Compile++ thumb: binder1 <= IPCThreadState.cpp
jni/IPCThreadState.cpp:292:8: error: 'pthread_mutex_t' does not name a type
jni/IPCThreadState.cpp:294:8: error: 'pthread_key_t' does not name a type
jni/IPCThreadState.cpp: In static member function 'static android::IPCThreadState* android::IPCThreadState::self()':
我使用 LOCAL_CFLAGS += -DHAVE_PTHREADS 修复了上述错误
但是现在,在生成库时,我得到了大量的错误列表。
D:/android-ndk-r9c-windows-x86/android-ndk-r9c/toolchains/arm-linux-androideabi- 4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux- androideabi/bin/ld.exe: error: cannot find -lpthread
D:/android-ndk-r9c-windows-x86/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi/objs/binder1/Binder.o: in function android::Vector<android::String16>::do_copy(void*, void const*, unsigned int) const:jni/utils/TypeHelpers.h:142: error: undefined reference to 'android::String16::String16(android::String16 const&)'
任何帮助将不胜感激。