Android支持pthreads吗? 为什么当我使用-pthread选项时,我看到链接器错误:
i686-android-linux / bin / ld:找不到-lpthread
#include <pthread.h>
#include <cxxabi.h>
extern "C" int printf (const char *, ...);
int main()
{
try
{
pthread_exit (0);
}
catch (abi::__forced_unwind &)
{
printf ("caught forced unwind\n");
throw;
}
catch (...)
{
printf ("caught ...\n");
return 1;
}
}
答案 0 :(得分:7)
据我所知,您不需要使用“-pthread”。结帐如下:
http://mobilepearls.com/labs/native-android-api/#pthreads
PThread implementation:
Bionic's C library comes with its own pthread implementation bundled in. This is different from other historical C libraries which: - place it in an external library (-lpthread) - play linker tricks with weak symbols at dynamic link time
所以请记住,Bionic包含直接pthread而不是您习惯的标准方式(使用-lpthread)。