Android培训班(24)
2010-12-25 21:17
495 查看
<!--
@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
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去执行。
@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
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培训班(24)
- Android培训班(24)
- Android培训班(71)Dex文件里类定义dvmDefineClass
- Android培训班(60)dex文件格式
- Android培训班(81)Dalvik虚拟机的垃圾回收3
- Android培训班(93)内核解压过程6
- Android 编译工具升级到24后遇到的坑之V4包的Fragment
- Technical Bulletin: Android SDK Build-tools 24
- Android培训班(5)
- Android开发教程24:UI之网格视图:GridView
- How to work around Android’s 24 MB memory limit
- Android培训班(20)
- Android培训班(36)
- Android培训班(79)Dalvik虚拟机的垃圾回收1
- Android培训班(37)
- Android培训班(114)start_kernel函数11
- 小强的HTML5移动开发之路(24)—— PhoneGap Android开发环境搭建
- Android培训班(75)Dalvik虚拟机的GetStaticMethodID函数
- Android培训班(64)dex文件格式5
- Android菜鸟的成长笔记(24)——Android中的振动器