building android 问题

本文介绍了一种在Linux环境下编译Android源代码时遇到的关于pthread库未定义引用的错误,并提供了一个简单的补丁来解决这个问题。

While I am building android on my linux box have this

error happen:
host Executable: localize (out/host/linux-x86/obj/EXECUTABLES/
localize_intermediates/localize)
out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/
libutils.a(Threads.o): In function `androidCreateRawThreadEtc':
/home/hmepas/android/src/frameworks/base/libs/utils/Threads.cpp:144:
undefined reference to `pthread_create'
/home/hmepas/android/src/frameworks/base/libs/utils/Threads.cpp:138:
undefined reference to `pthread_attr_setstacksize'
out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/
libcutils.a(threads.o): In function `thread_store_set':
/home/hmepas/android/src/system/core/libcutils/threads.c:36: undefined
reference to `pthread_key_create'
/home/hmepas/android/src/system/core/libcutils/threads.c:44: undefined
reference to `pthread_setspecific'
out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/
libcutils.a(threads.o): In function `thread_store_get':
/home/hmepas/android/src/system/core/libcutils/threads.c:27: undefined
reference to `pthread_getspecific'
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/localize_intermediates/
localize] Ошибка 1

And the same while building aapt module. To solve this you have to use
simple patch:
$ cat ld_pthread.patch
--- frameworks/base/tools/aapt/Android.mk.horig 2009-01-17 15:24:03
+0300
+++ frameworks/base/tools/aapt/Android.mk       2009-01-17 15:24:13
+0300
@@ -37,7 +37,7 @@ LOCAL_STATIC_LIBRARIES := /
 LOCAL_LDLIBS := -lz

 ifeq ($(HOST_OS),linux)
-LOCAL_LDLIBS += -lrt
+LOCAL_LDLIBS += -lrt -lpthread
 endif

 ifeq ($(HOST_OS),windows)
--- frameworks/base/tools/localize/Android.mk.horig     2009-01-17
15:36:08 +0300
+++ frameworks/base/tools/localize/Android.mk   2009-01-17 15:36:18
+0300
@@ -34,7 +34,7 @@ LOCAL_STATIC_LIBRARIES := /
       libcutils

 ifeq ($(HOST_OS),linux)
-LOCAL_LDLIBS += -lrt
+LOCAL_LDLIBS += -lrt -lpthread
 endif


Probs would be good idea to commit it to the branch =)

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值