Autoconf 未正确定义变量
我在我的项目中使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您没有调用
autoheader
,则config.h.in
可能已过时,并且可能不会提及HAVE_CHECKED
。我建议您放弃命令序列并使用autoreconf
代替,它将运行您需要的内容。If you didn't call
autoheader
thenconfig.h.in
may be out of date and may not mentionHAVE_CHECKED
. I suggest you just ditch your sequence of commands and useautoreconf
instead, it will run what you need.您确定要
#include
吗?这就是定义HAVE_CHECKED
的地方。编辑
当您不使用完整形式的
AC_DEFINE
时,我的 autoheader 版本会抱怨并失败:因此您的
config.h.in
不会'即使您确实调用了 autoheader,也不会得到更新。Are you making sure to
#include <config.h>
? That's whereHAVE_CHECKED
will be defined.EDIT
My version of autoheader complains and fails when you don't use the full form of
AC_DEFINE
:So your
config.h.in
wouldn't be getting updated even if you did call autoheader.