# \[Linux] Compiling OTClientV8 Sources

## Supported OS

* Debian
* Ubuntu 20.04
* Ubuntu 22.04
* Ubuntu 24.04

## 1. Install the required software:

<details>

<summary>Debian</summary>

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

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 -y
sudo apt install git cmake build-essential autoconf libtool ca-certificates curl zip unzip tar pkg-config ninja-build libglew-dev libx11-dev ccache linux-headers-$(uname -r) -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:

```
- 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
```

#### Install vcpkg:

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

**Update vcpkg if you already have installed:**

```
cd vcpkg
git pull
.\vcpkg upgrade
.\bootstrap-vcpkg.sh
.\vcpkg upgrade --no-dry-run
```

</details>

<details>

<summary>Ubuntu 20.04</summary>

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

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 -y
sudo apt install git cmake build-essential autoconf libtool ca-certificates curl zip unzip tar pkg-config ninja-build libglew-dev libx11-dev ccache linux-headers-$(uname -r) -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
```

#### Install vcpkg:

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

**Update vcpkg if you already have installed:**

```
cd vcpkg
git pull
.\vcpkg upgrade
.\bootstrap-vcpkg.sh
.\vcpkg upgrade --no-dry-run
```

</details>

<details>

<summary>Ubuntu 22.04</summary>

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

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 -y
sudo apt install git cmake build-essential autoconf libtool ca-certificates curl zip unzip tar pkg-config ninja-build libglew-dev libx11-dev ccache linux-headers-$(uname -r) -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
```

#### Install vcpkg:

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

**Update vcpkg if you already have installed:**

```
cd vcpkg
git pull
.\vcpkg upgrade
.\bootstrap-vcpkg.sh
.\vcpkg upgrade --no-dry-run
```

</details>

<details>

<summary>Ubuntu 24.04</summary>

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

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 -y
sudo apt install git cmake build-essential autoconf libtool ca-certificates curl zip unzip tar pkg-config ninja-build libglew-dev libx11-dev ccache linux-headers-$(uname -r) -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
```

#### Install vcpkg:

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

**Update vcpkg if you already have installed:**

```
cd vcpkg
git pull
.\vcpkg upgrade
.\bootstrap-vcpkg.sh
.\vcpkg upgrade --no-dry-run
```

</details>

## 2. Download the source code:

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

## 3. Checkout nightly branch (optional):

```
git checkout main
```

## 4. Folder structure:

```
.
├── otcv8
└── 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!**
