Skip to content

Compiling on WSL Ubuntu 22.04

Majesty edited this page May 23, 2024 · 6 revisions

Canary

Supported OS

  • Windows 10
  • Windows 11

1. Install the required software

The following command will install Git, CMake, a compiler and the libraries used by Canary.

Git will be used to download the source code, and CMake will be used to generate the build files.

sudo apt update && sudo apt dist-upgrade
sudo apt install git cmake build-essential autoconf libtool ca-certificates curl zip unzip tar pkg-config ninja-build ccache linux-headers-generic

Update cmake

1 - Uninstall the default version provided by Ubuntu's package manager and configuration:
sudo apt purge --auto-remove cmake
hash -r

2 - Prepare for installation:
sudo apt update && sudo apt install -y software-properties-common lsb-release && sudo apt clean all

3 - Obtain a copy of kitware's signing key:
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null

4 - Add kitware's repository to your sources list:
sudo apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main"

5 - Install the kitware-archive-keyring package:
sudo apt update && sudo apt install kitware-archive-keyring && sudo rm /etc/apt/trusted.gpg.d/kitware.gpg

6 - Verify key signature:
sudo apt update
Note: If running sudo apt update gets the following error:
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 42D5A192B819C5DA
Copy the public key 42D5A192B819C5DA and run this command:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 42D5A192B819C5DA

7 - Install CMake:
sudo apt update
sudo apt install cmake
cmake --version

Update gcc

sudo apt update
sudo apt install gcc-12 g++-12
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 --slave /usr/bin/g++ g++ /usr/bin/g++-12 --slave /usr/bin/gcov gcov /usr/bin/gcov-12
sudo update-alternatives --set gcc /usr/bin/gcc-12
gcc-12 --version
g++-12 --version

Install vcpkg

cd ~
git clone https://github.com/microsoft/vcpkg
cd vcpkg
./bootstrap-vcpkg.sh
cd ..

2. Download the source code

git clone --depth 1 https://github.com/opentibiabr/canary.git
cd canary

3. Checkout nightly branch (optional)

git checkout main

4. Folder structure

.
├── canary
└── vcpkg

5. Configure and build

mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake .. --preset linux-release
cmake --build linux-release

-- Running vcpkg install

This step will take a long time on the first run, as it needs to download and install all the dependencies, so be patient!