# \[WSL] Compiling Canary Sources

## 1 **- Install WSL:**&#x20;

* <https://learn.microsoft.com/en-us/windows/wsl/install>

## 2 - Install a Linux Distribution:

* [Debian](https://apps.microsoft.com/store/detail/debian/9MSVKQC78PK6?hl=pt-br\&gl=br)
* [Ubuntu 20.04](https://apps.microsoft.com/store/detail/ubuntu-20045-lts/9MTTCL66CPXJ?hl=pt-br\&gl=br)
* [Ubuntu 22.04](https://apps.microsoft.com/store/detail/ubuntu-22042-lts/9PN20MSR04DW?hl=pt-br\&gl=br)
* [Ubuntu 24.04](https://apps.microsoft.com/detail/9nz3klhxdjp5?hl=pt-br\&gl=BR)

## **3 - Compiling Canary Sources:**

<details>

<summary>Debian</summary>

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

Update cmake:

```
sudo nano /etc/wsl.conf
- Append these lines:
[boot]
systemd=true
- Save the file.
- Close your WSL distro and run the command below from PowerShell to restart your WSL instances:
wsl.exe --shutdown
- After the restart, open WSL distro again.

sudo apt remove --purge cmake -y
hash -r
sudo apt install snapd -y
sudo snap install cmake --classic
- Close your WSL distro and run the command below from PowerShell to restart your WSL instances:
wsl.exe --shutdown
- After the restart, open WSL distro again.
cmake --version
```

Update gcc:

```
- Edit repository file: 
sudo nano /etc/apt/sources.list

- Append these lines to the end:
deb http://deb.debian.org/debian testing main contrib non-free
deb-src http://deb.debian.org/debian testing main contrib non-free
- Save the file.

sudo apt update
sudo apt install gcc-14 -t testing && sudo apt install g++-14 -t testing
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 14 
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 14
gcc-14 --version
g++-14 --version
```

\-

```
sudo apt install acl
cd ~

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

git clone --depth 1 https://github.com/opentibiabr/canary.git
sudo setfacl -R -m g:www-data:rx /home/$USER/
sudo setfacl -R -m g:www-data:rx /home/$USER/canary
cd canary
mv config.lua.dist config.lua
mkdir build && cd build

cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake .. --preset linux-release -DTOGGLE_BIN_FOLDER=ON
cmake --build linux-release -j4

cd ~
cd canary
cp -r build/linux-release/bin/canary .
sudo chmod +x canary
```

</details>

<details>

<summary>Ubuntu 20.04</summary>

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

Update cmake:

```
sudo apt remove --purge cmake -y
hash -r
sudo apt install snapd -y
sudo snap install cmake --classic
cmake --version
```

Update gcc:

```
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt update
sudo apt install gcc-13 g++-13 -y
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 --slave /usr/bin/g++ g++ /usr/bin/g++-13 --slave /usr/bin/gcov gcov /usr/bin/gcov-13
sudo update-alternatives --set gcc /usr/bin/gcc-13
gcc-13 --version
g++-13 --version
```

\-

```
sudo apt install acl
cd ~

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

git clone --depth 1 https://github.com/opentibiabr/canary.git
sudo setfacl -R -m g:www-data:rx /home/$USER/
sudo setfacl -R -m g:www-data:rx /home/$USER/canary
cd canary
mv config.lua.dist config.lua
mkdir build && cd build

cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake .. --preset linux-release -DTOGGLE_BIN_FOLDER=ON
cmake --build linux-release -j4

cd ~
cd canary
cp -r build/linux-release/bin/canary .
sudo chmod +x canary
```

</details>

<details>

<summary>Ubuntu 22.04</summary>

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

Update cmake:

```
sudo apt remove --purge cmake -y
hash -r
sudo apt install snapd -y
sudo snap install cmake --classic
cmake --version
```

Update gcc:

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

\-

```
sudo apt install acl
cd ~

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

git clone --depth 1 https://github.com/opentibiabr/canary.git
sudo setfacl -R -m g:www-data:rx /home/$USER/
sudo setfacl -R -m g:www-data:rx /home/$USER/canary
cd canary
mv config.lua.dist config.lua
mkdir build && cd build

cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake .. --preset linux-release -DTOGGLE_BIN_FOLDER=ON
cmake --build linux-release -j4

cd ~
cd canary
cp -r build/linux-release/bin/canary .
sudo chmod +x canary
```

</details>

<details>

<summary>Ubuntu 24.04</summary>

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

Update cmake:

```
sudo apt remove --purge cmake -y
hash -r
sudo apt install snapd -y
sudo snap install cmake --classic
cmake --version
```

Update gcc:

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

\-

```
sudo apt install acl
cd ~

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

git clone --depth 1 https://github.com/opentibiabr/canary.git
sudo setfacl -R -m g:www-data:rx /home/$USER/
sudo setfacl -R -m g:www-data:rx /home/$USER/canary
cd canary
mv config.lua.dist config.lua
mkdir build && cd build

cmake -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake .. --preset linux-release -DTOGGLE_BIN_FOLDER=ON
cmake --build linux-release -j4

cd ~
cd canary
cp -r build/linux-release/bin/canary .
sudo chmod +x canary
```

</details>

### • How to update vcpkg:

<details>

<summary>If you already have vcpkg installed</summary>

To update vcpkg installation, run the commands below:

* cd vcpkg
* git pull
* ./vcpkg upgrade
* ./vcpkg upgrade --no-dry-run
* ./bootstrap-vcpkg.sh

</details>

### Observations:

{% hint style="info" %}
\-- 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!**
{% endhint %}

## **4 - Installation Nginx + MariaDB + MyAAC:** <a href="#id-3-installation-nginx--mariadb--myaac" id="id-3-installation-nginx--mariadb--myaac"></a>

* After compiling Canary sources, follow the tutorial below to install Nginx + MariaDB + MyAAC:
* [Nginx + MariaDB + MyAAC](https://docs.opentibiabr.com/opentibiabr/projects/canary/getting-started/installing/linux/nginx-+-mariadb-+-myaac)

## **5 - Credits:** <a href="#id-4-credits" id="id-4-credits"></a>

* **Majesty (Tutorial Compiling Canary Sources)**
