Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yiyuzhuang opened this issue Mar 2, 2024 · 0 comments

Comments

@yiyuzhuang
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant