c++11 std::unique_ptr error cmake 3.11.3 bootstrap

c++11 std::unique_ptr error cmake 3.11.3 bootstrap

  • 前言
  • 錯誤訊息
  • 解決辦法
  • 參考連結

前言

這是筆者在VirtualBox裡的Ubuntu 16.04下按照How do I install the latest version of cmake from the command line?安裝cmake時,其中一步./bootstrap所報的錯。

錯誤訊息

節錄部份錯誤訊息如下:

---------------------------------------------
CMake 3.16.5, Copyright 2000-2019 Kitware, Inc. and Contributors
C compiler on this system is: cc   
C++ compiler on this system is: /usr/bin/g++  -std=gnu++1z  
Makefile processor on this system is: make
/usr/bin/g++ has setenv
/usr/bin/g++ has unsetenv
/usr/bin/g++ does not have environ in stdlib.h
/usr/bin/g++ has stl wstring
/usr/bin/g++ has 
---------------------------------------------

//many lines...

CMake Error at CMakeLists.txt:107 (message):
  The C++ compiler does not support C++11 (e.g.  std::unique_ptr).


-- Configuring incomplete, errors occurred!
See also "/home/ubt/Documents/implementation/cmake-3.16.5/CMakeFiles/CMakeOutput.log".
See also "/home/ubt/Documents/implementation/cmake-3.16.5/CMakeFiles/CMakeError.log".
---------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
---------------------------------------------

解決辦法

這個錯誤的原因是cmake的根目錄被放在一個mounted directory之下,因此解決方法就是把cmake根目錄移到其它非mounted directory下,然後重新執行./bootstrap即可。

過程中可能出現以下錯誤:

CMake Error: The current CMakeCache.txt directory /home/ubt/cmake-3.16.5/CMakeCache.txt is different than the directory /home/ubt/Documents/implementation/cmake-3.16.5 where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
---------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
---------------------------------------------

這時候要先下:

rm -r CMakeCache.txt CMakeFiles/ Bootstrap.cmk/

來刪除前次./bootstrap所生成的檔案,接著再重新執行./bootstrap

以下是成功執行的輸出:

---------------------------------------------
CMake 3.16.5, Copyright 2000-2019 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc   
C++ compiler on this system is: g++  -std=gnu++17  
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 
---------------------------------------------

參考連結

c++11 std::unique_ptr error cmake 3.11.3 bootstrap

你可能感兴趣的:(C++)