问题描述
问候.我正在尝试创建一个autoconf配置脚本,该脚本会自动检查要使用的pthread选项,并且在使用gcc进行编译时最好指定-pthread.
Greetings. I am trying to create an autoconf configure script that automatically checks for which pthread option to use and, ideally, specifies -pthread when compiling with gcc.
我希望AX_PTHREAD可以工作,但似乎都不能在MacOS 10.6上工作.
It was my hope that AX_PTHREAD would work, but neither seems to work on MacOS 10.6.
我正在使用 http://www.nongnu.org/autoconf- archive/ax_pthread.html
出于我不了解的原因,它只是不将-pthread选项用于在Mac上构建的脚本.
For reasons that I do not understand, it just doesn't use the -pthread option for scripts build on a mac.
问题似乎是"none"正在编译且没有错误,因此ax_pthread_flags变量中的其他线程未被检查.
The problem seems to be that "none" is compiling without error, and as a result the other threads in the ax_pthread_flags variable aren't being checked.
因此,我已将-pthread案例移至"none"案例之前,并将此案例添加到case语句中:
So I've moved the -pthread case before the "none" case and added this case to the case statement:
-pthread)
PTHREAD_CFLAGS="-pthread"
PTHREAD_LIBS="-pthread"
;;
这似乎可行,但是我不确定它是否适用于非GCC编译器.而且我什至不确定我是否应该在意.
This seems to work, but I am not sure if it will work with non-GCC compilers. And I'm not even sure if I should care.
同样令人讨厌的是,AX_PTHREAD宏仅更新CFLAGS,而不更新CPPFLAGS.
Equally annoying is the fact that the AX_PTHREAD macro only updates CFLAGS, not CPPFLAGS.
是否有更好的方法使用autoconf测试-pthread选项?
Is there a better way to test for the -pthread option using autoconf?
推荐答案
PostgreSQL的AX_PTHREAD遭黑客入侵,可以解决一些问题: http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/config/acx_pthread.m4 . PostgreSQL建立在Mac OS X上,因此请尝试一下.
PostgreSQL has a hacked version of AX_PTHREAD that addresses some problems: http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/config/acx_pthread.m4 . PostgreSQL builds on Mac OS X, so give it a try perhaps.
这篇关于用-pthread自动配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!