首页 > 解决方案 > cmake 和 /opt/cmake/bin/cmake 显示不同的版本

问题描述

我对 C++ 编程和 cmake 很陌生。如果问题看起来很简单,请多多包涵。

我正在构建一个应用程序,其中 cmake 3.9.0 是所需的最低版本。

Setup.sh: Building rpclib with libc++.
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  CMake 3.9.0 or higher is required.  You are running version 3.5.1

所以我计划升级cmake版本并点击以下链接。

cmake_installation

注意:为了清楚起见,我不想清除现有版本,因为它可能会影响我系统中的ROS环境。

我已经完成了下面给出的安装和结果。

当我运行时cmake -version

kk@kk-Lenovo-ideapad-320-15ISK:~/cmake-3.9.0$ cmake -version 
cmake version 3.5.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).
kk@kk-Lenovo-ideapad-320-15ISK:~/cmake-3.9.0$ 

当我跑步时/opt/cmake/bin/cmake -version

kk@kk-Lenovo-ideapad-320-15ISK:~/cmake-3.9.0$ /opt/cmake/bin/cmake --version
cmake version 3.9.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).
kk@kk-Lenovo-ideapad-320-15ISK:~/cmake-3.9.0$

应用程序构建的问题/错误与以前相同。

您能否帮我更新 cmake 或修复此现有版本问题。

谢谢

KK

标签: c++cmake

解决方案


这听起来像是一个 PATH 问题。您必须更改 PATH 变量,以便 Setup.sh 在早期版本之前找到您的 cmake。在运行 Setup.sh 之前尝试此操作

export PATH=/opt/cmake/bin:$PATH

推荐阅读