
在configure.ac我写道:
for f in '-std=c++11' '-std=c++11 -stdlib=libc++'do AX_CHECK_COMPILE_FLAG([$f],[CXXFLAGS="$CXXFLAGS $f" stdpass=true],[],[])${stdpass-false} && breakdoneif ! "${stdpass-false}"; then AC_MSG_ERROR([Unable to turn on C++11 mode with this compiler])fi 使用gcc我没有问题,一切顺利,选项-std = c 11仅适用于g而不适用于gcc.
如果我尝试配置:
CC=clang ./configure
我有以下错误:
checking whether C compiler accepts -std=c++11... nochecking whether C compiler accepts -std=c++11 -stdlib=libc++... noconfigure: error: Unable to turn on C++11 mode with this compiler
这就像是选项是应用于C编译器而不仅仅是在clang上(就像使用gcc一样).
有人可以帮我弄清楚我做错了什么.
解决方法 好的,经过一些调查后我得到了答案.首先,在configure.ac中我必须设置我使用的语言:
AC_LANG([C])AC_LANG([C++])
然后,已经有一个autoconf宏来检查C编译器中的C 11支持:AX_CXX_COMPILE_STDCXX_11.
所以,点这个链接:https://www.gnu.org/software/automake/manual/html_node/Local-Macros.html,
我必须创建一个m4文件夹并将宏定义放在里面.继续进行的最佳方法是仅下载更通用的ax_cxx_compile_stdcxx.m4文件(而不是ax_cxx_compile_stdcxx_11.m4).
所以,总是在configure.ac我写道:
AC_CONfig_MACRO_DIR([m4])
和
m4_include([m4/ax_cxx_compile_stdcxx.m4])AX_CXX_COMPILE_STDCXX(11,noext,mandatory)
和Voilà.一切都很好,至少在我测试的机器上.
总结以上是内存溢出为你收集整理的如何使用autotools使用clang和选项-std = c 11编译项目全部内容,希望文章能够帮你解决如何使用autotools使用clang和选项-std = c 11编译项目所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)