Ubuntu系统CMake Error: Generator: execution of make failed.

今天需要make一些代码的时候,在Ubuntu 20.04.4 LTS下提示gmake 找不到,于是我打开makefile 发现 make=gmake

root@2a03b162414a:/data/jenkins/workspace/*/build# cat -n CMakeCache.txt | grep make
     3	# It was generated by CMake: /usr/bin/cmake
     4	# You can edit this file to change values found and used by cmake.
     109 //Path to a program.
   	 110 CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/gmake

发现 gmake 是 make 的 GNU 版本。我在我的 ubuntu 里面 search 这个软件包。结果没找到 apt-cache search 也没找到。难道 gmake 这么出名的字啊 sourcelist 里面没有?去 Ubuntu forum 里面看了一下说 ubuntu 把别名改了。make 就可以充当 gmake

报错现象

root@d3a89affd3d9:/data/jenkins/workspace/*/build# cmake ..
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
CMake Error: Generator: execution of make failed. Make command was: /usr/bin/gmake cmTC_92566/fast && 
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
  The C compiler

    "/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /data/jenkins/workspace/*/build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/gmake cmTC_92566/fast && No such file or directory
    Generator: execution of make failed. Make command was: /usr/bin/gmake cmTC_92566/fast && 
    
  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!
See also "/data/jenkins/workspace/*/build/CMakeFiles/CMakeOutput.log".
See also "/data/jenkins/workspace/*/build/CMakeFiles/CMakeError.log".

解决办法

gmake是GNU Make的缩写。Linux系统环境下的make就是GNU Make,之所以有gmake,是因为在别的平台上,make一般被占用,GNU make只好叫gmake了。比如在安装二进制文件进行编译时要使用make命令,但如果在非GNU系统中运行,必须使用GNU make,而不是使用系统自带的make版本,这时要用gmake代替make进行编译。

sudo ln -s /usr/bin/make /usr/bin/gmake

这样搞定。可以用 gmake 编译了。当然我还是建议通过 apt-get install.
Heaven and the abyss boys will march forward

你可能感兴趣的:(Ubuntu,ubuntu,jenkins,linux,devops,运维)