12

我正在尝试在 Ubuntu 16.04.4 LTS xenial 上引导 cmake 3.11.3。

我已经升级了我的 gnu g++ 编译器,如下所示:

> $ g++ --version
g++ (Ubuntu 8.1.0-5ubuntu1~16.04) 8.1.0 Copyright (C) 2018 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.

并手动重新指向符号链接:

$ ll /usr/bin/*g++*
lrwxrwxrwx 1 root root       5 Jun  8 16:57 /usr/bin/g++ -> g++-8*
-rwxr-xr-x 1 root root  919832 Apr 24 15:02 /usr/bin/g++-5*
lrwxrwxrwx 1 root root      22 Jun  6 04:26 /usr/bin/g++-8 -> x86_64-linux-gnu-g++-8*
lrwxrwxrwx 1 root root      22 Jun  8 16:58 /usr/bin/x86_64-linux-gnu-g++ -> x86_64-linux-gnu-g++-8*
lrwxrwxrwx 1 root root       5 Apr 24 15:02 /usr/bin/x86_64-linux-gnu-g++-5 -> g++-5*
-rwxr-xr-x 1 root root 1071984 Jun  6 04:26 /usr/bin/x86_64-linux-gnu-g++-8*

但是,我在 cmake 的配置中收到以下错误:

$ sudo ./bootstrap 
---------------------------------------------
CMake 3.11.3, Copyright 2000-2018 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc       
C++ compiler on this system is: g++          
Makefile processor on this system is: make
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
---------------------------------------------
make: Warning: File 'Makefile' has modification time 2.3 s in the future
make: 'cmake' is up to date.
make: warning:  Clock skew detected.  Your build may be incomplete.
loading initial cache file /mnt/ganymede/user/gpeytavi/srv_admin/software/cmake-3.11.3/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!
See also "/mnt/ganymede/user/gpeytavi/srv_admin/software/cmake-3.11.3/CMakeFiles/CMakeOutput.log".
See also "/mnt/ganymede/user/gpeytavi/srv_admin/software/cmake-3.11.3/CMakeFiles/CMakeError.log".
---------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
---------------------------------------------

知道为什么我会收到std::unique_ptr不符合 c++11 的错误吗?

4

4 回答 4

6

就我而言,问题是因为我拥有 CMake 源代码的文件夹位于挂载目录中(实际上我的整个 rootfs 都挂载在 NFS 上)所以,我查看了“挂载”命令输出并选择了“/run/user” /1000' 位置作为本地位置,因为它是使用 tmpfs 安装的,并将我的 CMake 源代码移动到该位置。有了这个, ./bootstrap && make && sudo make install 成功执行。

于 2020-03-24T04:12:53.750 回答
4

实际上,该./bootstrap脚本确实使用编译器尝试了不同的 C++ 标准标志。所以它应该自动检测它的能力。

请确保您没有设置任何CXXFLAGS环境变量并从头开始重试(您收到的消息/警告表明同一目录中有多次尝试/错误)。

成功时输出

作为我的 Ubuntu 调用 CMake 的参考,./bootstrap如下所示:

---------------------------------------------
CMake 3.11.20180423, Copyright 2000-2018 Kitware, Inc. and Contributors
Warning: This is an in-source build
Found GNU toolchain
C compiler on this system is: gcc
C++ compiler on this system is: g++  -std=gnu++1y
Makefile processor on this system is: make
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
---------------------------------------------

调试

为了调试您的问题,您还可以:

  • 称呼./bootstrap --verbose
  • 调查Bootstrap.cmk/cmake_bootstrap.log

已知问题

我只有一次在bootstrap使用clang需要执行以下调用的编译器时遇到问题:

export CXXFLAGS=-Xclang -std=c++1z -Xclang -stdlib=libc++

选择

如果您只想安装最新版本,请参阅如何指定 CMake 在 Ubuntu 中的安装位置?

于 2018-06-08T20:26:32.197 回答
0

通过在两者上运行 ntpd 确保构建机器和 NFS 文件服务器同步,我能够解决这个问题。

于 2021-05-28T22:05:08.870 回答
0

对我来说,这是时钟偏差。我使用以下命令:

date -s "2021-11-30 15:08:21" 

将服务器的时间设置为现在。然后就可以了,谢谢...

于 2021-11-30T07:32:57.330 回答