Skip to content

A compiling error is caused by "‘std::optional’ is only available from C++17 onwards". #13

@yiyuzhuang

Description

@yiyuzhuang

Problem:

When building the project, an error message is encountered: "‘std::optional’ is only available from C++17 onwards". This error occurs because the project uses the std::optional feature, which is available in C++17 and later versions, but the project is not configured to use C++17.

Solution:

To resolve this issue, set the C++ standard to C++17 in the project's CMakeLists.txt file by adding the following lines:

set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF)

These lines configure the project to use C++17, make it a required standard, and disable compiler-specific extensions. After adding these lines to the CMakeLists.txt file, re-run the CMake command to configure the project. The project should now be compiled using C++17, and the error related to std::optional should be resolved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions