Pep*_*lac 4 multithreading android gcc android-ndk
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;
}
}
Run Code Online (Sandbox Code Playgroud)
据我所知,你不需要使用"-pthread".结帐如下:http:
//mobilepearls.com/labs/native-android-api/#pthreads
来自NDK官方文档状态的信息(android-ndk-r8\docs\system\libc\OVERVIEW.html):
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).