CMake 运行错误could not find CMAKE_ROOT!!!

1. 之前使用cmake的时候一直都没有问题,结果今天再次使用的时候,出现了这样的一个错误提示:

CMake Error: Could not find CMAKE_ROOT !!!

CMake has most likely not been installed correctly. 
Modules directory not found in 
/usr/bin 
段错误 (核心已转储)

2.反复尝试了很多次仍然没有得到解决,不是出现could not find CMAKE_ROOT!!!的错误提示就是其他;就这样一直在卸载与安装中不断地反复的恶性循环,经过不停息的查资料,最终解决了这个问题;下面将我解决问题的每个步骤一一列举出来,供大家参考,相互学习;

(1) 步 : sudo apt-get remove cmake cmake-data 卸载 cmake-data包的东西一起删掉

(2)步:sudo -E add-apt-repository -y ppa:george-edison55/cmake-3.x(ppa 源中的版本修改)

(3)步:sudo -E apt-get update

(4)步:sudo apt-get install cmake

3.查看cmake版本号

linux终端使用:cmake -version可以查看到当前的cmake版本号是:

cmake version 3.8.2

可以看到现在已经是3.8.2版本,所以我在想会不会是因为之前的cmake的版本太低而导致一系列的这些问题;

4.执行完步骤2的所有操作项之后,再次使用cmake

root@Ubuntu:/home/lxg/code/项目/build# cmake …

结果:成功的运行,详细信息如下:
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
CMake Error at CMakeLists.txt:2 (add_executable):
  Cannot find source file:

    main.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx


CMake Error: CMake can not determine linker language for target: HelloWorld.bin
CMake Error: Cannot determine link language for target "HelloWorld.bin".
-- Generating done
-- Build files have been written to: /home/lxg/code/项目/build

同时在当前目录下生成了下列文件:

CMakeCache.txt  CMakeFiles  cmake_install.cmake  Makefile


你可能感兴趣的:(Linux应用开发)