Autoscan autoconf 生成的配置脚本无法在 c++ 中找到 cmath 函数;代码
我很困惑为什么 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您正在编译 C++ 代码,因此您应该切换 autoconf 以使用 C++ 运行其测试,例如
在检查之前添加。这将使用 C++ 运行测试,但仍然仅检查相应的 C 函数是否存在。请参阅此处的注意事项。
Since you are compiling C++ code you should switch autoconf to run its tests with C++, e.g. add
before your checks. This will run the tests with C++, but still only check existence of the corresponding C function. See caveats here.