tags:

views:

233

answers:

1

HI,

I am getting the following linker error on linux: My guess is it is missing '-lpthread' in the linker thread. My question is if there is a way for me to set my environment on linux such that it will add '-lpthread' when it links?

/usr/bin/ld: out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/libutils.a(Threads.o): in function androidCreateRawThreadEtc:frameworks/base/libs/utils/Threads.cpp:145: error: undefined reference to 'pthread_create'

Thank you.

A: 

You need to tell us more about how exactly you are compiling with gcc.

For example, if you are using a Makefile, the you can add -lpthread to the CFLAGS environment variable.

Edit: If you compile and link in two steps, then you should use the LDFLAGS environment variable for controlling the linker flags.

3lectrologos
Isn't CFLAGS normaly for compiling? I.e. if you have compiling and linking in two steps, you normaly use LDFLAGS for the linking.
emil
Yes, I assumed that he does compile and link in one step (because of the gcc tag). Updated my answer.
3lectrologos