一个月前,我用 cmake 3.9.6 在一台 debian squeeze 机器上安装了 cmake,并且运行良好。
\n\n现在,我正在另一台squeeze机器上安装cmake,但是当我这样做时它不起作用./configure。\n它说:
------------------------------------------------------------------------------------------\nCMake 3.10.1, Copyright 2000-2017 Kitware, Inc. and Contributors\nFound GNU toolchain\nC compiler on this system is: gcc \n---------------------------------------------\nError when bootstrapping CMake:\nCannot find a C++ compiler supporting C++11 on this system.\nPlease specify one using environment variable CXX.\nSee cmake_bootstrap.log for compilers attempted.\n---------------------------------------------\nLog of errors: /home/doom/things/cmake-3.10.1/Bootstrap.cmk/cmake_bootstrap.log\n---------------------------------------------\nRun Code Online (Sandbox Code Playgroud)\n\n和日志:
\n\n Checking for GNU toolchain\nTry: gcc\nLine: gcc cmake_bootstrap_28642_test.c -o cmake_bootstrap_28642_test\n---------- file -----------------------\nint main() { return 0; }\n------------------------------------------\nTest succeeded\nTry: g++\nLine: g++ cmake_bootstrap_28642_test.cpp -o cmake_bootstrap_28642_test\n---------- file -----------------------\nint main() { return 0; }\n------------------------------------------\nTest succeeded\nChecking whether \'gcc \' works.\nTry: gcc\nLine: gcc cmake_bootstrap_28642_test.c -o cmake_bootstrap_28642_test\n---------- file -----------------------\n\n#ifdef __cplusplus\n# error "The CMAKE_C_COMPILER is set to a C++ compiler"\n#endif\n\n#if defined(__sun) && __STDC_VERSION__ < 199901L\n#error "On Solaris we need C99."\n#endif\n\n#include <stdio.h>\n\nint main(int argc, char* argv[])\n{\n printf("%d%c", (argv != 0), (char)0x0a);\n return argc - 1;\n}\n\n------------------------------------------\n1\nTest succeeded\nChecking whether \'g++ \' works.\nTry: g++\nLine: g++ cmake_bootstrap_28642_test.cxx -o cmake_bootstrap_28642_test\n---------- file -----------------------\n\n#include <iostream>\n#include <memory>\n#include <unordered_map>\n\n#if __cplusplus < 201103L\n#error "Compiler is not in a mode aware of C++11."\n#endif\n\n#if defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140\n#error "SunPro <= 5.13 mode not supported due to bug in move semantics."\n#endif\n\nclass Class\n{\npublic:\n int Get() const { return this->Member; }\nprivate:\n int Member = 1;\n};\nint main()\n{\n auto const c = std::unique_ptr<Class>(new Class);\n std::cout << c->Get() << std::endl;\n return 0;\n}\n\n------------------------------------------\nIn file included from /usr/include/c++/4.4/unordered_map:35,\n from cmake_bootstrap_28642_test.cxx:4:\n/usr/include/c++/4.4/c++0x_warning.h:31:2: error: #error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.\ncmake_bootstrap_28642_test.cxx:7:2: error: #error "Compiler is not in a mode aware of C++11."\ncmake_bootstrap_28642_test.cxx:19: error: ISO C++ forbids initialization of member \xe2\x80\x98Member\xe2\x80\x99\ncmake_bootstrap_28642_test.cxx:19: error: making \xe2\x80\x98Member\xe2\x80\x99 static\ncmake_bootstrap_28642_test.cxx:19: error: ISO C++ forbids in-class initialization of non-const static member \xe2\x80\x98Member\xe2\x80\x99\ncmake_bootstrap_28642_test.cxx: In function \xe2\x80\x98int main()\xe2\x80\x99:\ncmake_bootstrap_28642_test.cxx:23: error: ISO C++ forbids declaration of \xe2\x80\x98c\xe2\x80\x99 with no type\ncmake_bootstrap_28642_test.cxx:23: error: \xe2\x80\x98unique_ptr\xe2\x80\x99 is not a member of \xe2\x80\x98std\xe2\x80\x99\ncmake_bootstrap_28642_test.cxx:23: error: expected primary-expression before \xe2\x80\x98>\xe2\x80\x99 token\ncmake_bootstrap_28642_test.cxx:24: error: base operand of \xe2\x80\x98->\xe2\x80\x99 is not a pointer\nTest failed to compile\nChecking whether \'g++ -std=gnu++1z\' works.\nTry: g++\nLine: g++ -std=gnu++1z cmake_bootstrap_28642_test.cxx -o cmake_bootstrap_28642_test\n---------- file -----------------------\n\n#include <iostream>\n#include <memory>\n#include <unordered_map>\n\n#if __cplusplus < 201103L\n#error "Compiler is not in a mode aware of C++11."\n#endif\n\n#if defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140\n#error "SunPro <= 5.13 mode not supported due to bug in move semantics."\n#endif\n\nclass Class\n{\npublic:\n int Get() const { return this->Member; }\nprivate:\n int Member = 1;\n};\nint main()\n{\n auto const c = std::unique_ptr<Class>(new Class);\n std::cout << c->Get() << std::endl;\n return 0;\n}\n\n------------------------------------------\ncc1plus: error: unrecognized command line option "-std=gnu++1z"\nTest failed to compile\nChecking whether \'g++ \' works.\nTry: g++\nLine: g++ cmake_bootstrap_28642_test.cxx -o cmake_bootstrap_28642_test\n---------- file -----------------------\n\n#include <iostream>\n#include <memory>\n#include <unordered_map>\n\n#if __cplusplus < 201103L\n#error "Compiler is not in a mode aware of C++11."\n#endif\n\n#if defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140\n#error "SunPro <= 5.13 mode not supported due to bug in move semantics."\n#endif\n\nclass Class\n{\npublic:\n int Get() const { return this->Member; }\nprivate:\n int Member = 1;\n};\nint main()\n{\n auto const c = std::unique_ptr<Class>(new Class);\n std::cout << c->Get() << std::endl;\n return 0;\n}\n\n------------------------------------------\nIn file included from /usr/include/c++/4.4/unordered_map:35,\n from cmake_bootstrap_28642_test.cxx:4:\n/usr/include/c++/4.4/c++0x_warning.h:31:2: error: #error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.\ncmake_bootstrap_28642_test.cxx:7:2: error: #error "Compiler is not in a mode aware of C++11."\ncmake_bootstrap_28642_test.cxx:19: error: ISO C++ forbids initialization of member \xe2\x80\x98Member\xe2\x80\x99\ncmake_bootstrap_28642_test.cxx:19: error: making \xe2\x80\x98Member\xe2\x80\x99 static\ncmake_bootstrap_28642_test.cxx:19: error: ISO C++ forbids in-class initialization of non-const static member \xe2\x80\x98Member\xe2\x80\x99\ncmake_bootstrap_28642_test.cxx: In function \xe2\x80\x98int main()\xe2\x80\x99:\ncmake_bootstrap_28642_test.cxx:23: error: ISO C++ forbids declaration of \xe2\x80\x98c\xe2\x80\x99 with no type\ncmake_bootstrap_28642_test.cxx:23: error: \xe2\x80\x98unique_ptr\xe2\x80\x99 is not a member of \xe2\x80\x98std\xe2\x80\x99\ncmake_bootstrap_28642_test.cxx:23: error: expected primary-expression before \xe2\x80\x98>\xe2\x80\x99 token\ncmake_bootstrap_28642_test.cxx:24: error: base operand of \xe2\x80\x98->\xe2\x80\x99 is not a pointer\nTest failed to compile\nChecking whether \'g++ -std=gnu++14\' works.\nTry: g++\nLine: g++ -std=gnu++14 cmake_bootstrap_28642_test.cxx -o cmake_bootstrap_28642_test\n---------- file -----------------------\n\n#include <iostream>\n#include <memory>\n#include <unordered_map>\n\n#if __cplusplus < 201103L\n#error "Compiler is not in a mode aware of C++11."\n#endif\n\n#if defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140\n#error "SunPro <= 5.13 mode not supported due to bug in move semantics."\n#endif\n\nclass Class\n{\npublic:\n int Get() const { return this->Member; }\nprivate:\n int Member = 1;\n};\nint main()\n{\n auto const c = std::unique_ptr<Class>(new Class);\n std::cout << c->Get() << std::endl;\n return 0;\n}\n\n------------------------------------------\ncc1plus: error: unrecognized command line option "-std=gnu++14"\nTest failed to compile\nChecking whether \'g++ -std=gnu++1y\' works.\nTry: g++\nLine: g++ -std=gnu++1y cmake_bootstrap_28642_test.cxx -o cmake_bootstrap_28642_test\n---------- file -----------------------\n\n#include <iostream>\n#include <memory>\n#include <unordered_map>\n\n#if __cplusplus < 201103L\n#error "Compiler is not in a mode aware of C++11."\n#endif\n\n#if defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140\n#error "SunPro <= 5.13 mode not supported due to bug in move semantics."\n#endif\n\nclass Class\n{\npublic:\n int Get() const { return this->Member; }\nprivate:\n int Member = 1;\n};\nint main()\n{\n auto const c = std::unique_ptr<Class>(new Class);\n std::cout << c->Get() << std::endl;\n return 0;\n}\n\n------------------------------------------\ncc1plus: error: unrecognized command line option "-std=gnu++1y"\nTest failed to compile\nChecking whether \'g++ \' works.\nTry: g++\nLine: g++ cmake_bootstrap_28642_test.cxx -o cmake_bootstrap_28642_test\n---------- file -----------------------\n\n#include <iostream>\n#include <memory>\n#include <unordered_map>\n\n#if __cplusplus < 201103L\n#error "Compiler is not in a mode aware of C++11."\n#endif\n\n#if defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140\n#error "SunPro <= 5.13 mode not supported due to bug in move semantics."\n#endif\n\nclass Class\n{\npublic:\n int Get() const { return this->Member; }\nprivate:\n int Member = 1;\n};\nint main()\n{\n auto const c = std::unique_ptr<Class>(new Class);\n std::cout << c->Get() << std::endl;\n return 0;\n}\n\n------------------------------------------\nIn file included from /usr/include/c++/4.4/unordered_map:35,\n from cmake_bootstrap_28642_test.cxx:4:\n/usr/include/c++/4.4/c++0x_warning.h:31:2: error: #error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.\ncmake_bootstrap_28642_test.cxx:7:2: error: #error "Compiler is not in a mode aware of C++11."\ncmake_bootstrap_28642_test.cxx:19: error: ISO C++ forbids initialization of member \xe2\x80\x98Member\xe2\x80\x99\ncmake_bootstrap_28642_test.cxx:19: error: making \xe2\x80\x98Member\xe2\x80\x99 static\ncmake_bootstrap_28642_test.cxx:19: error: ISO C++ forbids in-class initialization of non-const static member \xe2\x80\x98Member\xe2\x80\x99\ncmake_bootstrap_28642_test.cxx: In function \xe2\x80\x98int main()\xe2\x80\x99:\ncmake_bootstrap_28642_test.cxx:23: error: ISO C++ forbids declaration of \xe2\x80\x98c\xe2\x80\x99 with no type\ncmake_bootstrap_28642_test.cxx:23: error: \xe2\x80\x98unique_ptr\xe2\x80\x99 is not a member of \xe2\x80\x98std\xe2\x80\x99\ncmake_bootstrap_28642_test.cxx:23: error: expected primary-expression before \xe2\x80\x98>\xe2\x80\x99 token\ncmake_bootstrap_28642_test.cxx:24: error: base operand of \xe2\x80\x98->\xe2\x80\x99 is not a pointer\nTest failed to compile\nChecking whether \'g++ -std=gnu++11\' works.\nTry: g++\nLine: g++ -std=gnu++11 cmake_bootstrap_28642_test.cxx -o cmake_bootstrap_28642_test\n---------- file -----------------------\n\n#include <iostream>\n#include <memory>\n#include <unordered_map>\n\n#if __cplusplus < 201103L\n#error "Compiler is not in a mode aware of C++11."\n#endif\n\n#if defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140\n#error "SunPro <= 5.13 mode not supported due to bug in move semantics."\n#endif\n\nclass Class\n{\npublic:\n int Get() const { return this->Member; }\nprivate:\n int Member = 1;\n};\nint main()\n{\n auto const c = std::unique_ptr<Class>(new Class);\n std::cout << c->Get() << std::endl;\n return 0;\n}\n\n------------------------------------------\ncc1plus: error: unrecognized command line option "-std=gnu++11"\nTest failed to compile\nChecking whether \'g++ -std=gnu++0x\' works.\nTry: g++\nLine: g++ -std=gnu++0x cmake_bootstrap_28642_test.cxx -o cmake_bootstrap_28642_test\n---------- file -----------------------\n\n#include <iostream>\n#include <memory>\n#include <unordered_map>\n\n#if __cplusplus < 201103L\n#error "Compiler is not in a mode aware of C++11."\n#endif\n\n#if defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140\n#error "SunPro <= 5.13 mode not supported due to bug in move semantics."\n#endif\n\nclass Class\n{\npublic:\n int Get() const { return this->Member; }\nprivate:\n int Member = 1;\n};\nint main()\n{\n auto const c = std::unique_ptr<Class>(new Class);\n std::cout << c->Get() << std::endl;\n return 0;\n}\n\n------------------------------------------\ncmake_bootstrap_28642_test.cxx:7:2: error: #error "Compiler is not in a mode aware of C++11."\ncmake_bootstrap_28642_test.cxx:19: error: ISO C++ forbids initialization of member \xe2\x80\x98Member\xe2\x80\x99\ncmake_bootstrap_28642_test.cxx:19: error: making \xe2\x80\x98Member\xe2\x80\x99 static\ncmake_bootstrap_28642_test.cxx:19: error: ISO C++ forbids in-class initialization of non-const static member \xe2\x80\x98Member\xe2\x80\x99\nTest failed to compile\nRun Code Online (Sandbox Code Playgroud)\n\n但它在与 cmake 3.9.6 相同的机器上运行良好。
\n\ng++ 版本是gcc version 4.4.5 (Debian 4.4.5-8)。\n我的镜像上有最新版本。
确实是 g++ 版本的问题还是新版本的 cmake 的问题?
\n\n如果需要,如何从源安装 g++ 编译器?
\n\n感谢您的回答。
\n已弃用和删除的功能
不再支持使用 C++98 编译器构建 CMake 本身。CMake 现在使用 C++11 实现。
这需要一个有能力的编译器。GCC 的第一个版本是 GCC 4.8.1,它具有C ++ 11 功能。
Gcc 4.4.5 已经有7 年多了,更重要的是,它不支持 C++11(来自错误):
在此系统上找不到支持 C++11 的 C++ 编译器。
如上所述,您至少需要GCC 4.8.1。以下是一些指南:
| 归档时间: |
|
| 查看次数: |
18731 次 |
| 最近记录: |