【CMake】Your C++ compiler does NOT fully support C++17

项目场景:

编译YouCompleteMe时,遇到C++编译器不支持C++17,导致编译失败。


问题描述

  • 出错的关键日志
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:232 (message):
  Your C++ compiler does NOT fully support C++17.


-- Configuring incomplete, errors occurred!
See also "/tmp/ycm_build_ym0u6oos/CMakeFiles/CMakeOutput.log".
  •  gcc-11.2.0 已安装并且支持C++17,但不是安装在/usr/bin/目录下
  • 项目执行环境中已配置PATH优先为gcc-11.2.0的安装路径,执行c++显示的是11.2.0(正确)
  • 项目执行编译时,依然显示gcc是4.8.5,所以不支持C++17

原因分析:

通过 查看cmake/CMakeCache.txt 可知,原来,CMake在构建时,通过/usr/bin/c++进行判断其版本号来判断是否支持C++17。


解决方案:

 清除缓存  CMakeCache.txt,极有可能解决此问题

但最好效的方法是,执行环境中设置下CC和CXX的变量赋值

...

export CC=$(which gcc)
export CXX=$(which g++)
...

类似问题的解决参考

CMake complains about GCC version but newer is installed · Issue #5117 · Project-OSRM/osrm-backend · GitHub

  • 9
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值