Mac/Linux环境下出现 cmake: command not found

1、 原因

cmake: command not found`出现的原因有2个,一是未安装cmake, 二是因为环境变量中缺少路径。

本文主要针对环境变量中缺少路径情况。

2、解决方法

如何在环境变量中添加路径呢?只需要在用户根目录的.bash_profile中添加路径即可

2.1 方法一:永久添加 环境变量

# step1: open the .bash_profile 
$ cd 
$ touch .bash_profile
$ open .bash_profile  #for mac
#or
$ cd 
$ touch .bash_profile
$ vim .bash_profile  #for linux
# step2: Add Cmake Root to Path ,at the end of .bash_profile 
 export CMAKE_ROOT=/Applications/CMake.app/Contents/bin/
 export PATH=$CMAKE_ROOT:$PATH
 
#step3: update the .bash_profile
$ source .bash_profile

2.2、方法二:暂时添加 环境变量

此方法在bash窗口被关闭后即失效,再次使用需要重复执行。

# for temporary use
 export PATH="/Applications/CMake.app/Contents/bin":"$PATH"

3、查看是否解决

添加完成后,打开一个新的终端窗口,查看cmake版本号:

$ cmake --version
cmake version 3.15.2
  • 10
    点赞
  • 54
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值