[PATCH] to solve undefined reference to `pthread_create' while building cupcake on linux

1,063 views
Skip to first unread message

hmepas

unread,
Jan 17, 2009, 4:22:51 PM1/17/09
to android-platform
While I am building android on my linux box i 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 =)

David Turner

unread,
Jan 18, 2009, 3:42:26 PM1/18/09
to android-...@googlegroups.com
thanks a lot, please submit your patch through r.android.com
that's the fastest way to get it integrated into the source tree

regards

2009/1/17 hmepas <hme...@gmail.com>

Jean-Baptiste Queru

unread,
Jan 18, 2009, 9:41:31 PM1/18/09
to android-...@googlegroups.com
I can take care of uploading it after the week-end.

JBQ

2009/1/18 David Turner <di...@android.com>:

--
Jean-Baptiste M. "JBQ" Queru
Android Engineer, Google.

hmepas

unread,
Jan 21, 2009, 9:22:55 AM1/21/09
to android-platform
thanks jbq, i'll poke you with reminder then.

Jean-Baptiste Queru

unread,
Jan 21, 2009, 9:28:56 AM1/21/09
to android-...@googlegroups.com
Yup, I'll get to it as soon as I can. I've just been very busy
yesterday with other tasks that I had committed to doing but that
slipped a bit.

JBQ

2009/1/21 hmepas <hme...@gmail.com>:

Jean-Baptiste Queru

unread,
Jan 21, 2009, 10:44:10 AM1/21/09
to android-...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages