Skip to content

CLI Source Compilation Guide for windows, macOS and linux. #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

Phatcat
Copy link
Contributor

@Phatcat Phatcat commented May 5, 2025

Source compilation guide for all 3 targets using vcpkg or native package tools:
Requires the same Pr's that the build-runners do:

🔥 EMBER DOCUMENTATION: COMPILING EMBER USING CLI

Open a terminal at the directory you want to fetch Ember (/and vcpkg) into.

Windows Windows Logo

This guide is going to be assuming the C: drive but you can pick any folder;

cd C:\

This guide is assuming you are using powershell.
You can use cmd, but you need to amend the syntax of the multi line commands

macOS Apple Logo / Linux Linux (Tux) Logo

This guide is going to be assuming the $HOME directory but you can pick any directory;

cd $HOME

1. PRE-REQUIREMENTS:

In order to compile Ember from source some build tools are needed.
In particular we need git and cmake for this, as well as anything platform dependant.

Windows Windows Logo

Install build dependencies

winget install --id=Git.Git -e --silent --accept-package-agreements --accept-source-agreements; `
winget install --id=Kitware.CMake -e --silent --accept-package-agreements --accept-source-agreements; `
winget install --id=Ninja-build.Ninja -e --silent --accept-package-agreements --accept-source-agreements

Alternatively you can remove all the silent agreements and agree manually in the terminal as well as any popups.

macOS Apple Logo

MacOS pre-requirements

- Install xcode

xcode-select --install

- Install homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew update && \
brew upgrade

Install build dependencies

brew install git cmake make ninja curl

cmake can be added permanently to the path by amending the .zshrc file in $HOME to include this line

export PATH=/Applications/CMake.app/Contents/bin:$PATH

And then you can load the changes by running:

source ~/.zshrc
Linux Linux (Tux) Logo

Install build dependencies

apt-get -y update && apt-get -y upgrade && \
apt-get -y install software-properties-common && \
apt-get -y install git cmake make wget tar

Next we are going to acquire one (or several) of the compilers which we are going to use for compiling Ember;

Windows Windows Logo

- Install visual studio build tools for msvc

winget install --id=Microsoft.VisualStudio.2022.BuildTools -e --silent --accept-package-agreements --accept-source-agreements --override `
  "--add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.Windows10SDK `
   --add Microsoft.VisualStudio.Component.VC.Redist.MSM --includeRecommended"; `
& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\VsDevCmd.bat"

Follow the on-screen install instructions for visual studio,
- Additionally you can choose to include clang as an optional compiler by selecting it in individual packages

macOS Apple Logo

- Install either llvm for libc++ or gcc for libstdc++

a) Install llvm for libc++

brew install llvm

b) Install gcc for libstdc++

brew install gcc
Linux Linux (Tux) Logo

- Install either llvm for libc++ or gcc for libstdc++

a) Install llvm for libc++

apt-get -y install llvm && \
apt-get -y install llvm-dev

b) Install gcc for libstdc++

apt-get -y install build-essential && \
apt-get -y install libstdc++-dev

2. GETTING DEPENDENCIES:

Ember also needs a few libraries in order to compile, either manually or through vcpkg;

A) Install using vcpkg

Windows Windows Logo

- Download and install vcpkg:

git clone https://github.com/microsoft/vcpkg.git; `
.\vcpkg\bootstrap-vcpkg.bat; `
.\vcpkg\vcpkg integrate install
macOS Apple Logo

- Download and deploy vcpkg:

git clone https://github.com/microsoft/vcpkg.git && \
./vcpkg/bootstrap-vcpkg.sh && \
./vcpkg/vcpkg integrate install

vcpkg can be added permanently to the path by amending the .zshrc file in $HOME to include these lines

export VCPKG_ROOT=$HOME/vcpkg
export PATH=$VCPKG_ROOT:$PATH

And then you can load the changes by running:

source ~/.zshrc
Linux Linux (Tux) Logo

- Download and deploy vcpkg:

git clone https://github.com/microsoft/vcpkg.git && \
./vcpkg/bootstrap-vcpkg.sh && \
./vcpkg/vcpkg integrate install

B) Install using native tools and sources/precompiled binaries

Windows Windows Logo

- Steps incoming...

macOS Apple Logo

Packages through homebrew

brew install boost && \
brew install botan && \
brew install mysql-client && \
brew install openssl && \
brew install flatbuffers && \
brew install pcre && \
brew install zlib

Install MySQL Connector/C++

wget https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-9.3.0-macos15-arm64.tar.gz -O  && \
mkdir -p /usr/local/lib/cmake/mysql-concpp  && \
tar -zxf "mysql-connector-c++-9.3.0-macos15-arm64.tar.gz" -C /usr/local/lib/cmake/mysql-concpp --strip-components=1

Installing MySQL Connector/C++ headers and libraries.

mkdir -p /usr/local/include/mysql-concpp
cp -r /usr/local/lib/cmake/mysql-concpp/include/. /usr/local/include/mysql-concpp/
cp -r /usr/local/lib/cmake/mysql-concpp/lib64/. /usr/local/lib/
Linux Linux (Tux) Logo

Packages from apt-get

apt-get install -y libbotan-3-dev && \
apt-get install -y libmysqlclient-dev && \
apt-get install -y libssl-dev && \
apt-get install -y zlib1g-dev && \
apt-get install -y libpcre3-dev && \
apt-get install -y libflatbuffers-dev

Boost:

wget -q https://archives.boost.io/release/1.87.0/source/boost_1_87_0.tar.gz && \
tar -zxf boost_1_87_0.tar.gz && \
./boost_1_87_0/bootstrap.sh --with-libraries=system,program_options,headers && \
./boost_1_87_0/b2 link=static install -d0 -j $(nproc) cxxflags="-std=c++23"

Mysql-connector-c++:

arch=$(uname -m) && case "$arch" in \
  x86_64) url="https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-9.3.0-linux-glibc2.28-x86-64bit.tar.gz" ;; \
  aarch64) url="https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-9.3.0-linux-glibc2.28-aarch64.tar.gz" ;; \
  *) echo "Unsupported architecture: $arch" && exit 1 ;; esac && \
echo "Downloading MySQL Connector/C++ from ${url}" && \
wget "$url" -O /tmp/mysql-connector.tar.gz && \
mkdir -p /usr/lib/cmake/mysql-concpp && \
tar -zxf /tmp/mysql-connector.tar.gz -C /usr/lib/cmake/mysql-concpp --strip-components=1 && \
echo "Installing headers and libraries..." && \
mkdir -p /usr/include/mysql-cppconn && \
cp -r /usr/lib/cmake/mysql-concpp/include/* /usr/include/mysql-cppconn/ && \
cp -r /usr/lib/cmake/mysql-concpp/lib64/* /usr/local/lib/ && \
ldconfig && \
echo "MySQL Connector/C++ installed."

Patch the Botan config file for header paths: (THIS WILL BE PATCHED IN BOTAN 3.8!)

sh -c 'arch=$(dpkg-architecture -qDEB_HOST_MULTIARCH) && \
  BOTAN_CFG=$(find / -type f -iname "botan-config.cmake" 2>/dev/null | grep "/usr/lib/$arch" | head -n1) && \
  [ -n "$BOTAN_CFG" ] && \
  sed -i -e "s|\${_Botan_PREFIX}/include|/usr/include|g" -e "s|\${_Botan_PREFIX}/lib|/usr/lib/$arch|g" "$BOTAN_CFG"'

3. DOWNLOAD/UPDATE EMBER:

We are using git for both downloading and updating Ember

First time setting up Ember:

Windows Windows Logo / macOS Apple Logo / Linux Linux (Tux) Logo

Make sure you are in the directory where you want Ember to reside, then run the following git command:

git clone https://github.com/EmberEmu/Ember.git

Change the current directory to Ember for building:

cd Ember

Updating Ember:

Windows Windows Logo / macOS Apple Logo / Linux Linux (Tux) Logo

Open a terminal at the directory where Ember is cloned to and run the following git commands:

git fetch origin

This fetches the changes on the remote

git rebase origin/HEAD

And this applies it to your downloaded Ember repository.
This is assuming you've made no changes to the source code,
otherwise you have to stash or commit your changes before doing the rebase or it'll throw an error.

4. BUILD EMBER WITH CMAKE:

We are now ready to compile Ember using cmake and the compiler of your choice;

Windows Windows Logo

Build with cmake and msvc using visual studio build tools:

cmake -S . -B build -G "Visual Studio 17 2022" -A x64 `
  -DCMAKE_TOOLCHAIN_FILE="C:\vcpkg\scripts\buildsystems\vcpkg.cmake" `
  -DVCPKG_TARGET_TRIPLET=x64-windows-static `
  -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>" `
  -DCMAKE_INSTALL_PREFIX="\build\bin"

Then run the cmake --build, remember to configure either for release or debug:
Run this twice or it might failt to find the generated includes

cmake --build build --target install --config Debug
macOS Apple Logo

- cmake with either llvm for libc++ or gcc for libstdc++

a) llvm with libc++

cmake -S . -B build \
  -DCMAKE_TOOLCHAIN_FILE="$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake" \
  -DCMAKE_C_COMPILER="/opt/homebrew/opt/llvm/bin/clang" \
  -DCMAKE_CXX_COMPILER="/opt/homebrew/opt/llvm/bin/clang++" \
  -DCMAKE_INSTALL_PREFIX="/build/bin"

b) gcc with libstdc++

cmake -S . -B build \
  -DCMAKE_TOOLCHAIN_FILE="$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake" \
  -DCMAKE_C_COMPILER="/opt/homebrew/bin/gcc-14" \
  -DCMAKE_CXX_COMPILER="/opt/homebrew/bin/g++-14" \
  -DCMAKE_INSTALL_PREFIX="/build/bin"

Then run the cmake --build, remember to configure either for release or debug:

cmake --build build --target install --config Debug
Linux Linux (Tux) Logo

Generate Makefile & compile

cmake -S . -B build \
  -DCMAKE_TOOLCHAIN_FILE="$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake" \
  -DCMAKE_INSTALL_PREFIX="/build/bin"

Then run the cmake --build, remember to configure either for release or debug:

cmake --build build --target install --config Debug

Source compilation guide for all 3 targets using vcpkg or native package tools
@Phatcat Phatcat changed the title Create Source Compilation Guide.md CLI Source Compilation Guide for windows, macOS and linux. May 6, 2025
@Phatcat Phatcat marked this pull request as draft May 24, 2025 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant