C++ C++;编译器不支持C++;11(例如std::unique\u ptr)。建筑OpenWRT

C++ C++;编译器不支持C++;11(例如std::unique\u ptr)。建筑OpenWRT,c++,cmake,g++,openwrt,C++,Cmake,G++,Openwrt,我正在使用说明并在ubuntu中构建OpenWRT,但我得到: make[4]: Entering directory '~/openwrt/build_dir/host/cmake-3.11.1/Bootstrap.cmk' make[4]: 'cmake' is up to date. make[4]: Leaving directory '~/openwrt/build_dir/host/cmake-3.11.1/Bootstrap.cmk' loading initial cache f

我正在使用说明并在ubuntu中构建OpenWRT,但我得到:

make[4]: Entering directory '~/openwrt/build_dir/host/cmake-3.11.1/Bootstrap.cmk'
make[4]: 'cmake' is up to date.
make[4]: Leaving directory '~/openwrt/build_dir/host/cmake-3.11.1/Bootstrap.cmk'
loading initial cache file ~/openwrt/build_dir/host/cmake-3.11.1/Bootstrap.cmk/InitialCacheFlags.cmake
CMake Error at CMakeLists.txt:92 (message):
  The C++ compiler does not support C++11 (e.g.  std::unique_ptr).


-- Configuring incomplete, errors occurred!
有一个类似问题的解决方案,但是我不清楚在我的例子中哪个CMakeLists.txt文件是“根”。在OpenWRT论坛(或一般的搜索引擎)上没有看到太多关于这个失败的信息

我得到的印象是,CMake安装是由OpenWRT构建器本身下载的,因为我没有安装CMake,而安装CMake没有解决任何问题

已尝试签出最新的OpenWRT v18.06.2。当构建失败时,我删除了克隆目录并尝试v18.06.0-rc2。没有任何改善

也试过

导出CMAKE\U CXX\U标准=11

在运行“make”之前 ... 它没有解决这个问题

我的g++安装的状态:

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
哦,那是5个小时,我没有主意了。这可能是配置错误还是开发端的bug


如果配置错误,会有什么设置错误?

我的糟糕经历可能会帮助其他人。我有gcc 7.4.0。在同一台机器上,我对配置包没有问题。有一天,我决定建立一个优化的版本

export CXXFLAGS=O3

configure
... many lines ignored
checking whether g++ supports C++11 features by default... no
checking whether g++ supports C++11 features with -std=c++11... no
checking whether g++ supports C++11 features with +std=c++11... no
checking whether g++ supports C++11 features with -h std=c++11... no
checking whether g++ supports C++11 features with -std=c++0x... no
checking whether g++ supports C++11 features with +std=c++0x... no
checking whether g++ supports C++11 features with -h std=c++0x... no
configure: error: *** A compiler with support for C++11 language features is required.

注意:执行导出CXXFLAGS=“-O3”后,我的问题消失了。打字错误漏掉了破折号。希望这能帮助很多其他人。大多数困难都是由于我们犯了一个微妙的错误造成的。

我将我的解决方案粘贴在这里,以便有人能得到我的提示(也可能不是因为这个原因)

在搜索了数百万页之后,人们只是谈论为什么而不是如何,我的解决方案很简单:

将cmake源代码复制到我的系统驱动器。如果您在远程硬盘上创建cmake,它将失败并出错,就像上面所说的那样。当MAKEFLAGS设置为“-j8”时,我会遇到相同的错误(在Linux桌面上,与OpenWRT无关)。这是因为警告
gmake[1]:警告:-jN在submake中强制:禁用jobserver模式。
这使得cmake测试认为出了问题。嗯。 解决方法:
取消设置MAKEFLAGS


在任何情况下,调查此错误的方法都是读取CMakeFiles/CMakeError.log

g++接受命令行选项以支持更新的标准。例如
g++-std=c++11
。顺便说一句,它不会检查环境变量来启用类似的功能。您需要配置构建脚本以提供这些命令行选项。默认的“方言”取决于gcc/g++版本,但倾向于默认为稳定性,而不是最新版本(例如,2018年的gcc版本将默认为支持C++14或更早版本,而不是支持C++17-因此使用C++17需要您提供所需的命令行选项)@Peter感谢您的输入,但它甚至不是我的make脚本-它是OpenWRTs-它在使用相同软件包的相同OS版本的新VM安装上完成。在我的构建环境中有些东西被破坏了,我对它在哪里感到困惑。我甚至重新安装了所有的开发包,没有任何改进。export-cxflags=“-O3”真的解决了我两周来的头痛问题。非常感谢@Kemin Shou分享。