我正在尝试在 Linux (RHEL) 中安装 CMake。当我运行引导脚本时,它会抛出以下错误:
---------------------------------------------
CMake 3.5.2, Copyright 2000-2016 Kitware, Inc.
Found GNU toolchain
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C compiler on this system.
Please specify one using environment variable CC.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /usr/cmake-3.5.2/Bootstrap.cmk/cmake_bootstrap.log
**Contents of the log file are as follows**
Checking for GNU toolchain
Try: gcc
Line: gcc cmake_bootstrap_5875_test.c -o cmake_bootstrap_5875_test
---------- file -----------------------
int main() { return 0; }
------------------------------------------
Test succeeded
Try: g++
Line: g++ cmake_bootstrap_5875_test.cpp -o cmake_bootstrap_5875_test
---------- file -----------------------
int main() { return 0; }
------------------------------------------
Test succeeded
Try: gcc
Line: gcc cmake_bootstrap_5875_test.c -o cmake_bootstrap_5875_test
---------- file -----------------------
#ifdef __cplusplus
# error "The CMAKE_C_COMPILER is set to a C++ compiler"
#endif
#include<stdio.h>
#if defined(__CLASSIC_C__)
int main(argc, argv)
int argc;
char* argv[];
#else
int main(int argc, char* argv[])
#endif
{
printf("%d%c", (argv != 0), (char)0x0a);
return argc-1;
}
------------------------------------------
cmake_bootstrap_5875_test.c:6:18: error: stdio.h: No such file or directory
cmake_bootstrap_5875_test.c: In function 'main':
cmake_bootstrap_5875_test.c:16: warning: incompatible implicit declaration of built-in function 'printf'
Test failed to compile
我在目录 /usr/bin/ 中安装了 gcc 和 g++。
有人能帮我解决这个问题吗?
答案1
读取错误日志:
cmake_bootstrap_5875_test.c:6:18: error: stdio.h: No such file or directory
看起来 C 库的头文件没有正确安装。它们应该与 GCC 一起自动安装。您是否手动安装了 GCC?检查是否安装了“glibc-devel”包。