Autoscan autoconf 生成的配置脚本无法在 c++ 中找到 cmath 函数;代码

发布于 2024-12-25 20:35:59 字数 451 浏览 3 评论 0原文

我很困惑为什么 autoscan 和 autoconf 生成的配置脚本告诉我它在包含 cmath 的 C++ 代码中找不到函数 pow 和 sqrt 头文件。我正在调用 AC_CHECK_FUNCS([pow sqrt]) (返回“否”答案)。代码编译并运行得很好,没有任何错误。

C++ 代码:

#include <cmath>
...
x = sqrt(y);

configure.ac:

AC_CHECK_FUNCS([pow sqrt])

没有库检查,但我不需要在 cmath 的命令行上链接 -lm 。我不确定这是否是阻碍。看起来相当简单,所以我很困惑为什么它不起作用。仅供参考,g++ 4.1.2,autoconf 2.59,RedHat EL 5.3。

I'm confused why a configure script generated by autoscan and autoconf tells me it can't find the functions pow and sqrt in a c++ code that includes the cmath header file. I am calling AC_CHECK_FUNCS([pow sqrt]) (which returns a "no" answer). The code compiles and runs just fine, no errors whatsoever.

C++ code:

#include <cmath>
...
x = sqrt(y);

configure.ac:

AC_CHECK_FUNCS([pow sqrt])

There are no library checks, but I don't need to link -lm on the command line for cmath. I'm not sure if this is the holdup. Seems fairly simple, so I'm confused why it's not working. FYI, g++ 4.1.2, autoconf 2.59, RedHat EL 5.3.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空城旧梦 2025-01-01 20:35:59

由于您正在编译 C++ 代码,因此您应该切换 autoconf 以使用 C++ 运行其测试,例如

AC_LANG(C++)

在检查之前添加。这将使用 C++ 运行测试,但仍然仅检查相应的 C 函数是否存在。请参阅此处的注意事项

Since you are compiling C++ code you should switch autoconf to run its tests with C++, e.g. add

AC_LANG(C++)

before your checks. This will run the tests with C++, but still only check existence of the corresponding C function. See caveats here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文