我正在使用 android NDK 独立工具链编译 Qt/C++ 项目。我使用 make-standalone-toolchain.sh --arch=arm --toolchain=arm-linux-androideabi-4.9 --platform=android-21 命令创建了独立工具链。 NDK 版本是 android-ndk-r10e。目标项目使用 pthread 库中的一些函数。在编译时,我收到以下错误:
error: 'pthread_getaffinity_np' was not declared in this scope
const int err = pthread_getaffinity_np(_pthreadId, sizeof(cpu_set_t), &cpuSetMask);
compilation terminated due to -Wfatal-errors.
我检查了ndk工具链中包含的pthread的标头,但没有找到pthread_getaffinity_np函数的声明。
Android 的 pthread 功能是否受到限制?如何在 Android NDK 中正确使用 pthread?
Is pthread functionality for Android limited?
据我所知,是的。
http://mobilepearls.com/labs/native-android-api/#pthreads http://mobilepearls.com/labs/native-android-api/#pthreads
https://web.archive.org/web/20180602101341/http://mobilepearls.com/labs/native-android-api/#pthreads https://web.archive.org/web/20180602101341/http://mobilepearls.com/labs/native-android-api/#pthreads
POSIX threads (pthreads)
The android libc, bionic, provides built-in support for pthreads, so no
additional linking (-lpthreads) is necessary. It does not implement full
POSIX threads functionality and leaves out support for read/write locks,
pthread_cancel(), process-shared mutexes and condition variables as well as
other more advanced features. Read the bionic OVERVIEW.txt for more
information.
TLS, thread-local storage, is limited to 59 pthread_key_t slots available
to applications, lower than the posix minimum of 128.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)