cmake reported an error:
CMake 3.8 or higher is required. You are running version 3.5.1
It indicates that the current version of cmake is too low.
Installation steps:
1. View the current cmake version:
cmake -version
2. Uninstall the current cmake: (skip this step if ROS is installed)
sudo apt remove cmake
3. Download cmake:
Directly from cmake official website To download the new version, you can also execute the following statement:
wget http://www.cmake.org/files/v3.16/cmake-3.16.6.tar.gz
I download cmake-3.16.6 here.
Or go to the file library to download: https://cmake.org/files/v3.16/
Note: there are two versions on the official website, one is the Source version, and the other is Linux x86 ʄ in Binary distributions. This is a compiled executable version that can be used directly. You only need to establish a soft connection, and call cmake GUI to use cmake by establishing a soft link.
What I download here is the source version ending with. tar.gz.
4. Decompression and installation:
tar xf cmake-3.16.6.tar.gz #Unzip, or right-click to extract it directly cd cmake-3.16.6
sudo apt-get install build-essential
Go to the folder, if there is a lock indicating that there is permission setting, return to the upper directory of cmake-3.16.6, and modify the file permission
sudo chmod -R 777 cmake-3.16.6
./bootstrap
If there is an error in this step, please refer to the following solutions for errors.
make
make install
verification:
cmake --version
Solutions to errors encountered:
Error 1: an error occurred while running. / bootstrap:
-- Looking for gethostname -- Looking for gethostname - found -- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR) CMake Error at Utilities/cmcurl/CMakeLists.txt:454 (message): Could not find OpenSSL. Install an OpenSSL development package or configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL. -- Configuring incomplete, errors occurred! See also "/home/whlg/cmake-3.16.6/CMakeFiles/CMakeOutput.log". See also "/home/whlg/cmake-3.16.6/CMakeFiles/CMakeError.log". --------------------------------------------- Error when bootstrapping CMake: Problem while running initial CMake ---------------------------------------------
Prompt: OpenSSL cannot be found, check error log, missing package.
Solution:
sudo apt-get install libssl-dev
Rerun
./bootstrap
Error 2: error reported when make install:
[100%] Built target foo Install the project... -- Install configuration: "" CMake Error at Source/kwsys/cmake_install.cmake:41 (file): file cannot create directory: /usr/local/doc/cmake-3.16/cmsys. Maybe need administrative privileges. Call Stack (most recent call first): cmake_install.cmake:42 (include) Makefile:76: recipe for target 'install' failed make: *** [install] Error 1
Solution:
sudo make install
Error 3: when executing cmake --version, it indicates that there is no file or directory:
bash: /usr/bin/cmake: no file or directory
Solution:
Use which cmake to find the installation path of cmake, which is in / usr/local/bin/cmake by default, and the system will search in / usr/bin by default.
Make a link:
ln -s /usr/local/bin/cmake /usr/bin
Add sudo if you don't have permission.
Reference link:
How to upgrade cmake in Ubuntu [duplicate]