来源: “码农不会写诗”公众号
链接:DEBUG-ninja: xxx was unable to find xxx corresponding to “Ninja”
Ninja 是一款注重速度的小型编译系统。其通过解析构建文件建立一个有向无环任务图,通过图的依赖关系确定需要构建的任务并且并行执行,极大的提高构建效率!
01 现象描述
以下为使用Ninja基于cmake编译时的报错信息,只要是出现类似xxx was unable to find a build program corresponding to “Ninja”,本文均适用
CMake Error: CMake was unable to find a build program corresponding to “Ninja”. CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
– Configuring incomplete, errors occurred!
02 原因分析
使用Ninja基于cmake构建编译任务时,没有找到名为ninja的可执行文件,也就是没有安装Ninja
03 解决方案
sudo apt-get update
sudo apt-get install ninja-build -y
04 内容总结
在使用ninja前,可通过以下命令确认是否安装及查看版本是否正确
ninja --version
未安装:
bash: /usr/bin/ninja: No such file or directory
已安装,输出版本号:
1.10.1