Android NDK和pthread [英] Android NDK and pthread

查看:68
本文介绍了Android NDK和pthread的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android NDK独立工具链编译Qt/C ++项目.我使用make-standalone-toolchain.sh --arch = arm --toolchain = arm-linux-androideabi-4.9 --platform = android-21命令创建了独立工具链.NDK版本为android-ndk-r10e.目标项目使用pthread库中的某些功能.在编译时,出现以下错误:

I'm compiling Qt/C++ project with android NDK standalone toolchain. I’ve created standalone toolchain with make-standalone-toolchain.sh --arch=arm --toolchain=arm-linux-androideabi-4.9 --platform=android-21 command. NDK version is android-ndk-r10e. Target project uses some functions from pthread library. At compile time, I get the following error:

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函数的声明.

I've checked the header of pthread included in ndk toolchain and I did not find the declaration of pthread_getaffinity_np function.

Android的pthread功能是否受限制?如何在Android NDK中正确使用pthread?

Is pthread functionality for Android limited? How to use pthread with Android NDK properly?

推荐答案

Android的pthread功能是否受限制?

AFAIK,是的.

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.

这篇关于Android NDK和pthread的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆