Android培训班(24)
<!-- @page { margin: 2cm } P { margin-bottom: 0.21cm } -->
问题1:
Copying: out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes-full-debug.jar
Install: out/host/linux-x86/framework/dx.jar
Install: out/host/linux-x86/bin/dx
host Executable: aapt (out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt)
/usr/bin/ld: out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): in function thread_store_set:system/core/libcutils/threads.c:36: error: undefined reference to pthread_key_create
/usr/bin/ld: out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): in function thread_store_set:system/core/libcutils/threads.c:44: error: undefined reference to pthread_setspecific
/usr/bin/ld: out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): in function thread_store_get:system/core/libcutils/threads.c:27: error: undefined reference to pthread_getspecific
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] 错误 1
Android-2.0$">tony@tony-desktop:~/android/Android-2.0$
解决这个出错的办法,找到目录:
/home/tony/android/Android-2.0/frameworks/base/tools/aapt
然后打开文件Android.mk,编辑下面一行:
LOCAL_LDLIBS := -lz
ifeq ($(HOST_OS),linux)
#LOCAL_LDLIBS += -lrt 把这行注释掉,改为下面一行。
LOCAL_LDLIBS += -lrt -lpthread
endif
请问编译时加-lpthread有何作用?
链接多线程的库,在程序中用到了pthread.h头文件中的函数时需要加这个选项。编译时加与不加-lpthread,在执行时究竟有哪些具体区别呢?
区别在于 ELF解析器,而不是内核。内核execve返回到用户空间时,执行的是interpreter;如果有链接到libpthread库,interpreter程序会先加载这个库,然后再回到a.out去执行
补充:移动开发 , Android ,