vcpkg is a C and C++ package manager to acquire and manage libraries.
You can download over 1,500 open-source libraries or add your own private libraries.
It’s maintained by the Microsoft C++ team and open-source contributors.
In this guide, you’ll learn how to install vcpkg on Ubuntu, test it, and uninstall it.
How to install vcpkg on Ubuntu
To install vcpkg on Ubuntu, you need to prepare the environment and install vcpkg from the GitHub repository.
Step 1: Prepare the environment
sudo apt update
sudo apt install -y zip unzip
Step 2: Install build-essential and pkg-config packages
sudo apt install -y build-essential pkg-config
Step 3: Install vcpkg from GitHub
wget -O vcpkg.tar.gz https://github.com/microsoft/vcpkg/archive/master.tar.gz
Step 4: Make a new directory to hold vcpkg and extract the tar.gz file
sudo mkdir /opt/vcpkg
sudo tar xf vcpkg.tar.gz --strip-components=1 -C /opt/vcpkg
Step 5: Build vcpkg
sudo /opt/vcpkg/bootstrap-vcpkg.sh
Step 6: Make a symbolic link to the vcpkg command in “/usr/local/bin”
sudo ln -s /opt/vcpkg/vcpkg /usr/local/bin/vcpkg
Step 7: Check the version of vcpkg
vcpkg version
Step 8: Remove the tar.gz file
rm -rf vcpkg.tar.gz
How to test vcpkg on Ubuntu
To test vcpkg on Ubuntu, you need to install the zlib library and get a list of installed libraries by running two separate commands.
1. Install the zlib library
sudo vcpkg install zlib:x64-linux
2. Get a list of installed libraries
sudo vcpkg list
How to uninstall vcpkg on Ubuntu
To completely uninstall vcpkg on Ubuntu, you need to delete the vcpkg installation directory, delete the symbolic link, clear the cache and related directories, and uninstall the related packages and dependencies.
1. Delete the vcpkg installation directory
sudo rm -rf /opt/vcpkg
2. Delete the symbolic link
sudo rm -rf /usr/local/bin/vcpkg
3. Clear the cache and related directories
sudo rm -rf /root/.cache/vcpkg
sudo rm -rf /root/.vcpkg
rm -rf ~/.vcpkg
4. Uninstall related packages and dependencies
sudo apt purge --autoremove -y zip unzip build-essential cpp make binutils pkg-config