六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 72|回复: 0

Android培训班(24)

[复制链接]

升级  53.65%

673

主题

673

主题

673

主题

探花

Rank: 6Rank: 6

积分
2073
 楼主| 发表于 2013-2-1 11:13:56 | 显示全部楼层 |阅读模式
<!--@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
hostExecutable: 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去执行。
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表