Install vcpkg on Ubuntu 24.04

Install vcpkg on Ubuntu 24.04

The vcpkg is a cross-platform C/C++ package manager for downloading and building various libraries. The vcpkg is an open-source project developed by Microsoft, which released under the MIT license.

This tutorial explains how to install vcpkg on Ubuntu 24.04.

Prepare environment

Make sure you have installed Git in your system. You can read post how to install it.

Also, you need to install zip and unzip packages:

sudo apt update
sudo apt install -y zip unzip

For libraries compilation, you need to install build-essential and pkg-config packages:

sudo apt install -y build-essential pkg-config

Install vcpkg

Download vcpkg from GitHub repository:

wget -qO vcpkg.tar.gz https://github.com/microsoft/vcpkg/archive/master.tar.gz

Create a new directory to store vcpkg and extract the tar.gz file to it:

sudo mkdir /opt/vcpkg
sudo tar xf vcpkg.tar.gz --strip-components=1 -C /opt/vcpkg

Run the following command to build vcpkg itself:

sudo /opt/vcpkg/bootstrap-vcpkg.sh

In /usr/local/bin directory, we can create a symbolic link to the vcpkg command:

sudo ln -s /opt/vcpkg/vcpkg /usr/local/bin/vcpkg

Now vcpkg can be used as a system-wide command for all users. We can check vcpkg version with command:

vcpkg version

The tar.gz file is no longer needed, remove it:

rm -rf vcpkg.tar.gz

Testing vcpkg

We can use vcpkg install command to build and install libraries. For example, the following command installs zlib library:

sudo vcpkg install zlib:x64-linux

Run the following command to get a list of installed libraries:

sudo vcpkg list

Uninstall vcpkg

If you wish to completely remove vcpkg, delete the installation directory:

sudo rm -rf /opt/vcpkg

Remove symbolic link:

sudo rm -rf /usr/local/bin/vcpkg

You can also remove vcpkg cache and related directories:

sudo rm -rf /root/.cache/vcpkg
sudo rm -rf /root/.vcpkg
sudo rm -rf /tmp/vcpkg
rm -rf ~/.vcpkg

For environment preparation, we needed to install various packages. These packages and related dependencies can be completely removed with command:

sudo apt purge --autoremove -y zip unzip build-essential cpp make binutils pkg-config

The 2 Comments Found

  1. Avatar
    Unknown Reply

    This is perhaps the most usefull tutorial on th e internet for a newbe cpp programmer. A simple explenation is sometimes the best explanation.

  2. Avatar
    Glenn Reply

    Very nice and clean tutorial ! Especially making use of "/opt/" directory, and not filling up the home dir.
    Great job and thanks !

Leave a Comment

Cancel reply

Your email address will not be published.