android - 交叉编译到arm时找不到lpthread

标签 android arm pthreads cross-compiling

这是我目前的问题。现在我正在尝试将基于 x86 的项目移植到 android。但该项目需要pthread库支持,无法通过配置阶段。

命令:

./configure --build=${BUILD_SYS} --host=arm-eabi  --prefix=${PREFIX} --disable-rpath --disable-libasprintf --disable-java --disable-native-java --disable-openmp --disable-curses

编译器和编译标志:

export CFLAGS="--sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${PREFIX}/include -I${NDK}/sources/android/support/include -pthread -fPIE -DANDROID -Wno-multichar"
export CXXFLAGS=${CFLAGS}
export CPPFLAGS="--sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${PREFIX}/include -I${NDK}/sources/android/support/include -pthread -DANDROID -DNO_XMALLOC -mandroid"
export LIBS="-lc -lgcc -lstdc++ -ldl"
export LDFLAGS="-Wl,-L${SYSROOT}/usr/lib -L${PREFIX}/lib -L${NDK_TOOLCHAIN}/lib"

错误消息:

checking for WIN32... no
checking for Mac... no
checking for Linux... compile in linux
checking for uuid_generate in -luuid... yes
found library uuid
checking for pthread_create in -lpthread... no
configure: error: *** Unable to find pthread library

请帮忙解决:如何附加正确的标志? OR 如何欺骗autoconf? OR 如何交叉编译libpthread? 并且最终通过编译。

最佳答案

Android 的 POSIX 线程(pthreads):

android libc,仿生,提供对 pthreads 的内置支持, so no additional linking (-lpthreads) is necessary. 它没有实现完整的 POSIX 线程功能并省略了对读/写锁的支持, pthread_cancel()、进程共享互斥体和条件变量以及 其他更高级的功能。

因此不需要添加 -lpthreads 并删除检查。

关于android - 交叉编译到arm时找不到lpthread,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38666609/

相关文章:

android - 不可变位图崩溃错误

ARM : What's the difference between APCS and AAPCS ABI?

c - 使用互斥体设置 pthread 的优先级

linux - 在 Linux 中是否有一种异步安全的方法来获取当前线程 ID?

android - 如何在 Box Android API 中获取特定的 mp3 文件路径?

android - 当我不使用 ContigouslyPagedList 时,ContigouslyPagedList onPageError

android - 使用 Retrofit 通过请求主体将 String[] 数组发送到 Web 服务

gdbserver 跟踪点臂支持

recursion - ARM 程序集 - 斐波那契实现 : PUSH and POP not working as expected

c++ - 即使使用 lpthread 也有 undefined reference to `pthread_join' 错误