使用 -pthread 自动配置 [英] autoconf with -pthread

查看:18
本文介绍了使用 -pthread 自动配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好.我正在尝试创建一个 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-的 AX_PTHREAD-存档/ax_pthread.html

由于我不明白的原因,它只是不为在 mac 上构建的脚本使用 -pthread 选项.

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"案例之前,并将此案例添加到案例语句中:

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 自动配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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