
In this article, we will walk you through the process of installing the latest version of CMake on Ubuntu 18.04.3 LTS run via Windows Subsystem for Linux (WSL). We will also guide you through resolving a common OpenSSL error that you may encounter during the bootstrap stage.
To install the latest version of CMake on Ubuntu 18.04.3 LTS via WSL, you can either update CMake using the official Kitware repository or manually install it. If you encounter an OpenSSL error during the process, you can resolve it by installing the OpenSSL development package.
Prerequisites
Before we start, make sure you have administrative access to your Ubuntu system and that it’s updated to the latest version.
Installing OpenSSL Development Package
The first step in our process is to install the OpenSSL development package. OpenSSL is a robust, full-featured open-source toolkit that implements the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols. This package is essential for creating the SSL certificates that CMake requires.
To install the OpenSSL development package, open your WSL terminal and run the following command:
sudo apt-get install libssl-dev
This command uses the apt-get install
function to download and install the libssl-dev
package. The sudo
command gives you administrative privileges, which are necessary for installing packages.
Updating CMake Using the Official Kitware Repository
If the OpenSSL error persists after installing the OpenSSL development package, you can try updating CMake using the official Kitware repository.
To do this, run the following commands in your WSL terminal:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates gnupg software-properties-common wget
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
sudo apt-get update
sudo apt-get install cmake
These commands perform the following actions:
sudo apt-get update
updates the package list on your Ubuntu system.sudo apt-get install apt-transport-https ca-certificates gnupg software-properties-common wget
installs necessary packages for fetching data from secure HTTPS sources.wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
downloads and adds the Kitware GPG key to your system.sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
adds the Kitware repository to your system’s software repository list.sudo apt-get update
updates your system’s package list again, this time including the newly added Kitware repository.sudo apt-get install cmake
installs the latest version of CMake.
Manually Installing CMake
If the above method doesn’t work, you can manually download and install the latest version of CMake.
First, visit the official CMake website and download the appropriate Ubuntu version file.
Once downloaded, extract the file into the directory where you maintain your projects. For example, if your projects are in a folder called “Github,” extract the file into that folder.
In your WSL terminal, navigate to the extracted folder (cmake-{version number}) and run the following commands:
cmake .
make
make install
These commands perform the following actions:
cmake .
configures the build process by generating native makefiles or workspaces that can be used in the compiler environment of your choice.make
builds the executables.make install
installs the executables.
After the installation is complete, locate the /bin/
folder inside the CMake folder. Ensure that a file called “cmake” is present in this folder. Copy the path of this directory.
Open the ~/.bash_aliases
file in your terminal using a text editor (e.g., sudo nano ~/.bash_aliases
). Add the following line at the end of the file, replacing {PATH to /bin/ folder}
with the copied path:
alias cmake="{PATH to /bin/ folder}/cmake"
Save the file and exit. Restart your terminal and run the command cmake --version
to verify that the latest version of CMake is installed.
Conclusion
In this article, we have guided you through the process of installing the latest version of CMake on Ubuntu 18.04.3 LTS via WSL, and resolving a common OpenSSL error. We hope this guide has been helpful. If you encounter any issues during the installation process, please refer to the official Kitware directions.
CMake is an open-source cross-platform build system that helps in managing the build process of software projects. It generates native build files that can be used with different compilers and build environments.
Yes, you can install CMake directly on your Ubuntu system without using WSL. You can follow similar steps to install CMake on Ubuntu by using the package manager or manually downloading and installing it from the official CMake website.
The OpenSSL development package is required by CMake to create SSL certificates. These certificates are used for secure communication between different components of a software project.
You can check the version of CMake installed on your Ubuntu system by running the command cmake --version
in your terminal. It will display the installed version of CMake.
Yes, you can use a different version of CMake than the latest one. If you have a specific version requirement for your project, you can download and install that particular version of CMake from the official CMake website or use a package manager to install a specific version available in the repository.
To uninstall CMake from your Ubuntu system, you can use the package manager. Run the command sudo apt-get remove cmake
in your terminal to remove the installed CMake package.