Autoconf 未正确定义变量

发布于 2024-09-25 14:36:47 字数 630 浏览 9 评论 0原文

我在我的项目中使用 GNU 自动工具。 configure.ac 脚本具有以下代码片段。

AC_ARG_WITH(chkhere,
 AC_HELP_STRING([--without-chkhere], [do not compile]),
 [ac_cv_chkhere=$withval], [ac_cv_chkhere=yes])

# Check if chkhere is available
if test "x$ac_cv_chkhere" = "xyes"
then
 AC_DEFINE(HAVE_CHECKED)
 echo "chkhere: enabled"
else
  echo "chkhere: DISABLED"
fi

我正在检查 C++ 代码中的变量 HAVE_CHECKED。这适用于 --without-chkhere 选项。

当我给出 ./configure --with-chkhere 时,它​​会根据需要显示消息“chkhere:启用”,但 HAVE_CHECKED 在 C++ 代码中显示为未定义。

请建议我哪里出错了,或者我是否可以以不同的方式进行测试?谢谢。

PS:我正在遵循以下命令序列:automake; libtoolize; aclocal -I m4;自动配置;

I am using GNU autotools for my project. The configure.ac script has the following snippet.

AC_ARG_WITH(chkhere,
 AC_HELP_STRING([--without-chkhere], [do not compile]),
 [ac_cv_chkhere=$withval], [ac_cv_chkhere=yes])

# Check if chkhere is available
if test "x$ac_cv_chkhere" = "xyes"
then
 AC_DEFINE(HAVE_CHECKED)
 echo "chkhere: enabled"
else
  echo "chkhere: DISABLED"
fi

And I am checking for the variable HAVE_CHECKED in the C++ code. This works for --without-chkhere option.

When I am giving ./configure --with-chkhere, it shows the message "chkhere: enabled" as required, but HAVE_CHECKED turns up undefined inside the C++ code.

Please suggest where I am going wrong, or if I can test this differently? Thanks.

P.S.: I am following this sequence of commands: automake; libtoolize; aclocal -I m4; autoconf;

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

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

发布评论

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

评论(2

旧时光的容颜 2024-10-02 14:36:47

如果您没有调用 autoheader,则 config.h.in 可能已过时,并且可能不会提及 HAVE_CHECKED。我建议您放弃命令序列并使用 autoreconf 代替,它将运行您需要的内容。

If you didn't call autoheader then config.h.in may be out of date and may not mention HAVE_CHECKED. I suggest you just ditch your sequence of commands and use autoreconf instead, it will run what you need.

离不开的别离 2024-10-02 14:36:47

您确定要#include吗?这就是定义 HAVE_CHECKED 的地方。

编辑

当您不使用完整形式的 AC_DEFINE 时,我的 autoheader 版本会抱怨并失败:

AC_DEFINE([HAVE_CHECKED], [1], [some description])

因此您的 config.h.in 不会'即使您确实调用了 autoheader,也不会得到更新。

Are you making sure to #include <config.h>? That's where HAVE_CHECKED will be defined.

EDIT

My version of autoheader complains and fails when you don't use the full form of AC_DEFINE:

AC_DEFINE([HAVE_CHECKED], [1], [some description])

So your config.h.in wouldn't be getting updated even if you did call autoheader.

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