Centos C++17安装求助

试玩Taskwarrior,编译失败,提示缺乏C++17 支持
尝试解决:
CentOS7安装c++17 - 简书

设置成功,升级到c++ (GCC) 7.3.1,但仍旧提示C++17 support missing.
VS版本、GCC版本与C++版本的对应关系_Captain–Jack的博客-CSDN博客_c++11是vs哪个版本
应该是支持的才对。

无解。求助。

[root@localhost task-2.6.2]# c++ --version
c++ (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@localhost task-2.6.2]# cmake -DCMAKE_BUILD_TYPE=release .
-- Configuring C++17
-- System: Linux
CMake Error at cmake/CXXSniffer.cmake:11 (message):
  C++17 support missing.  Try upgrading your C++ compiler.  If you have a
  good reason for using an outdated compiler, please let us know at
  [email protected].
Call Stack (most recent call first):
  CMakeLists.txt:10 (include)


-- Configuring incomplete, errors occurred!
See also "/opt/task-2.6.2/CMakeFiles/CMakeOutput.log".
See also "/opt/task-2.6.2/CMakeFiles/CMakeError.log".


还是报错:

cmake . -DCMAKE_CXX_STANDARD=17 /opt/rh/devtoolset-7/

报错:

[root@localhost task-2.6.2]# cmake . -DCMAKE_CXX_STANDARD=17 /opt/rh/devtoolset-7/
CMake Warning:
  Ignoring extra path from command line:

   "/opt/rh/devtoolset-7/"


-- Configuring C++17
-- System: Linux
CMake Error at cmake/CXXSniffer.cmake:11 (message):
  C++17 support missing.  Try upgrading your C++ compiler.  If you have a
  good reason for using an outdated compiler, please let us know at
  [email protected].
Call Stack (most recent call first):
  CMakeLists.txt:10 (include)

去掉路径也不行:

-- Configuring C++17
-- System: Linux
CMake Error at cmake/CXXSniffer.cmake:11 (message):
  C++17 support missing.  Try upgrading your C++ compiler.  If you have a
  good reason for using an outdated compiler, please let us know at
  [email protected].
Call Stack (most recent call first):
  CMakeLists.txt:10 (include)


-- Configuring incomplete, errors occurred!
See also "/opt/task-2.6.2/CMakeFiles/CMakeOutput.log".
See also "/opt/task-2.6.2/CMakeFiles/CMakeError.log".

指定g++的绝对路径,cmake -DCMAKE_CXX_COMPILER=path/to/g++

/path/to/g++换成你安装的g++的路径

是这样写吗?
cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++

还是不行:


root@localhost task-2.6.2]# cmake -DCMAKE_CXX_COMPILER=/usr/bin/g++
CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.


-- 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/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring C++17
-- System: Linux
-- Performing Test _HAS_CXX17
-- Performing Test _HAS_CXX17 - Failed
CMake Error at cmake/CXXSniffer.cmake:11 (message):
  C++17 support missing.  Try upgrading your C++ compiler.  If you have a
  good reason for using an outdated compiler, please let us know at
  [email protected].
Call Stack (most recent call first):
  CMakeLists.txt:10 (include)


-- Configuring incomplete, errors occurred!
See also "/opt/task-2.6.2/CMakeFiles/CMakeOutput.log".
See also "/opt/task-2.6.2/CMakeFiles/CMakeError.log".

你4.8哪来的c++17,我说的是你安装的g++7的路径

以下是经过验证的可行方法,可以试一下:

1、安装gcc安装包的镜像源
yum install centos-release-scl

2、安装gcc10和g++10
yum install devtoolset-10

3、针对当前shell启动新版本编译器
scl enable devtoolset-10 bash

4、开始 cmake 命令生成 makefile
cmake 编译参数

5、开始编译
make

说明:第三步,就是切换编译为 gcc10, 而不是使用默认的 4.8.5. cmake 还是原来的参数,不用指定编译器就用当前scl环境的 gcc10

4、开始 cmake 命令生成 makefile
cmake 编译参数
请教这一步该怎么写?

Taskwarrior - What’s next? - Taskwarrior

用官方的做法会报错:

[xxx@localhost ~]$ cmake -DCMAKE_BUILD_TYPE=release .
CMake Warning:
  Ignoring extra path from command line:

   "."


CMake Error: The source directory "/home/xxx" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

目录都没切,当然编译不了