Cmake文件以支持c++ 11
Cmake file to support C++11
我需要构建和制作源代码,但是出现这个错误:
error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
我在其他主题中看到,这很容易通过将CMakeLists.txt中的标志更改为'-std=c++11'来修复,但在构建目录中没有CMakeLists.txt。
有人能帮帮我吗?
——OBS:我是Ubuntu 16.04
在CMake项目中启用c++11的最干净的方法是在主CMakeLists.txt中设置变量CMAKE_CXX_STANDARD。
set(CMAKE_CXX_STANDARD 11)
您可能还需要将CMAKE_CXX_EXTENSIONS设置为off以使用-std=c++11而不是GCC扩展的默认-std=gnu++11。
变量和相关属性记录在这里:
https://cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_STANDARD.html变量:CMAKE_CXX_STANDARD
https://cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_EXTENSIONS.html相关文章:
- 编译时未启用intel oneApi CUDA支持
- POCO::PostgreSQL:如何将std::vector支持添加到`Binder::bind`
- 使用CMake检测支持的C++标准
- 为什么istream不支持右值提取
- 当我编译webrtc服务器时,Windows上只支持clang-cl
- 扩展光电二极管探测器以支持多个传感器
- MSVC是否支持C++11样式的属性而不是__declspec
- 在使用GPU支持编译Tensorflow时,会遇到CUDA_TOOLKIT_PATH未绑定变量
- 当使用比格式支持的精度更高的精度来显示数字时,会写出什么数据
- 错误:(-210:不支持的格式或格式组合)功能'create'中的硬件视频解码器不支持视频源
- 哪个C++规范开始支持 std::vector
- 如何检测VS C++编译器是否支持C++11?
- CertGetCertificateChain 具有支持的内存存储和证书信任列表
- Casablanca/cpprestsdk listener.support接受函数,但不支持方法
- 将 IPv6 支持添加到雨量计
- 为什么C++不支持对未初始化变量进行智能分析?
- LMDB 是否支持随机读取?
- 在 c++ 中连接字符串和整数,以便在 C++ 11 不支持计算机的情况下读取多个文件
- 在 Ubuntu 18.04 上编译 GLSL 着色器时"不支持 GLSL 3.30"?
- 如何在多写入器情况下对文件支持的共享内存中的大页面出错