clang 无法使用显式 CPPFLAGS 搜索路径进行 autoconf AC_CHECK_HEADER 检查
在一个几乎总是使用 GCC 构建的已建立的 autotools 管理项目中,我决定尝试使用 LLVM clang 作为 g++ 替代品,但发现它失败了使用标准 AC_CHECK_HEADER 宏的个人编写的标头检查。这是检查代码:
oldCPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS -I$GSLINCPATH"
AC_CHECK_HEADER([gsl/gsl_vector.h], [], [AC_MSG_ERROR([GSL vectors not found.])])
CPPFLAGS=$oldCPPFLAGS
这是失败消息:
checking gsl/gsl_vector.h usability... no
checking gsl/gsl_vector.h presence... no
checking for gsl/gsl_vector.h... no
configure: error: GSL vectors not found.
$GSLINCPATH 的值是 /usr/include (显式检查),/usr/include/gsl/gsl_vector.h 确实存在,并且此检查代码与 GCC 配合良好。临时切换修改后的 $CPPFLAGS 似乎是进行此测试的事实上的标准方法,但是是否有更好的方法,更便携?或者这个问题还有其他原因吗?
In an established autotools-managed project which is almost always built with GCC, I decided to try using LLVM clang as a g++ substitute, but found that it falls over on a personally-written header check that uses the standard AC_CHECK_HEADER macro. Here's the checking code:
oldCPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS -I$GSLINCPATH"
AC_CHECK_HEADER([gsl/gsl_vector.h], [], [AC_MSG_ERROR([GSL vectors not found.])])
CPPFLAGS=$oldCPPFLAGS
and here's the failure message:
checking gsl/gsl_vector.h usability... no
checking gsl/gsl_vector.h presence... no
checking for gsl/gsl_vector.h... no
configure: error: GSL vectors not found.
The value of $GSLINCPATH is /usr/include (explicitly checked), /usr/include/gsl/gsl_vector.h does exist, and this check code works nicely with GCC. The temporary switching in of a modified $CPPFLAGS seems to be the de facto standard way to do this test, but is there a better way that is more portable? Or is there another reason for this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论