Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions content/for-engine-devs/compiling/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ aliases:

# Compiling Luanti

This directory contains additional guides on how to compile Luanti for specific platforms in specific ways.

In addition to these guides, see [doc/compiling](https://github.com/luanti-org/luanti/tree/master/doc/compiling#compiling-luanti) for the compilation guides that are maintained by the Luanti engine core developers.
This directory contains additional guides on how to compile Luanti for specific
platforms in specific ways.
107 changes: 107 additions & 0 deletions content/for-engine-devs/compiling/linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
title: Linux
---

# Compiling on Linux

## Dependencies

| Dependency | Version | Commentary |
| ---------- | ------- | --------------------------------------- |
| GCC | 7.5+ | or Clang 7.0.1+ |
| CMake | 3.5+ | |
| libjpeg | - | |
| libpng | - | |
| SDL | 2.x | |
| Freetype | 2.0+ | |
| SQLite3 | 3+ | |
| Zlib | - | |
| Zstd | 1.0+ | |
| LuaJIT | 2.0+ | Bundled Lua 5.1 is used if not present |
| GMP | 5.0.0+ | Bundled mini-GMP is used if not present |
| JsonCPP | 1.0.0+ | Bundled JsonCPP is used if not present |
| Curl | 7.56.0+ | Optional |
| gettext | - | Optional |
| OpenSSL | 3.0+ | Optional (only libcrypto used) |

For Debian/Ubuntu users:

sudo apt install g++ make libc6-dev cmake libpng-dev libjpeg-dev libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev libgmp-dev libjsoncpp-dev libzstd-dev libluajit-5.1-dev gettext libsdl2-dev

For Fedora users:

sudo dnf install make automake gcc gcc-c++ kernel-devel cmake libcurl-devel openal-soft-devel libpng-devel libjpeg-devel libvorbis-devel libogg-devel freetype-devel mesa-libGL-devel zlib-devel jsoncpp-devel gmp-devel sqlite-devel luajit-devel leveldb-devel ncurses-devel spatialindex-devel libzstd-devel gettext SDL2-devel

For openSUSE users:

sudo zypper install gcc gcc-c++ cmake libjpeg8-devel libpng16-devel openal-soft-devel libcurl-devel sqlite3-devel luajit-devel libzstd-devel Mesa-libGL-devel libvorbis-devel freetype2-devel SDL2-devel

For Arch users:

sudo pacman -S --needed base-devel libcurl-gnutls cmake libpng libjpeg-turbo sqlite libogg libvorbis openal freetype2 jsoncpp gmp luajit leveldb ncurses zstd gettext sdl2

For Alpine users:

sudo apk add build-base cmake libpng-dev jpeg-dev mesa-dev sqlite-dev libogg-dev libvorbis-dev openal-soft-dev curl-dev freetype-dev zlib-dev gmp-dev jsoncpp-dev luajit-dev zstd-dev gettext sdl2-dev

For Void users:

sudo xbps-install cmake libpng-devel jpeg-devel mesa sqlite-devel libogg-devel libvorbis-devel libopenal-devel libcurl-devel freetype-devel zlib-devel gmp-devel jsoncpp-devel LuaJIT-devel zstd libzstd-devel gettext SDL2-devel

## Download

You can install Git for easily keeping your copy up to date.
If you don’t want Git, read below on how to get the source without Git.
This is an example for installing Git on Debian/Ubuntu:

sudo apt install git

For Fedora users:

sudo dnf install git

For Arch users:

sudo pacman -S git

For Alpine users:

sudo apk add git

For Void users:

sudo xbps-install git

Download source (this is the URL to the latest of source repository, which might not work at all times) using Git:

git clone --depth 1 https://github.com/luanti-org/luanti
cd luanti

Download source, without using Git:

wget https://github.com/luanti-org/luanti/archive/master.tar.gz
tar xf master.tar.gz
cd luanti-master

## Build

Build a version that runs directly from the source directory:

cmake . -DRUN_IN_PLACE=TRUE
make -j$(nproc)

Run it:

./bin/luanti

Run unit tests:

./bin/luanti --run-unittests

- Use `cmake . -LH` to see all CMake options and their current state.
- If you want to install it system-wide (or are making a distribution package),
you will want to use `-DRUN_IN_PLACE=FALSE`.
- You can build a bare server by specifying `-DBUILD_SERVER=TRUE`.
- You can disable the client build by specifying `-DBUILD_CLIENT=FALSE`.
- You can select between Release and Debug build by `-DCMAKE_BUILD_TYPE=<Debug or Release>`.
- Debug build is slower, but gives much more useful output in a debugger.
103 changes: 103 additions & 0 deletions content/for-engine-devs/compiling/macos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
title: MacOS
---

# Compiling on MacOS

## Requirements

- [Homebrew](https://brew.sh/)
- [Git](https://git-scm.com/downloads)

Install dependencies with homebrew:

```
brew install cmake freetype gettext gmp hiredis jpeg-turbo jsoncpp leveldb libogg libpng libvorbis luajit zstd gettext
```

## Download

Download source (this is the URL to the latest of source repository, which might not work at all times) using Git:

```bash
git clone --depth 1 https://github.com/luanti-org/luanti luanti
cd luanti
```

## Building for personal usage

### Build

```bash
mkdir build
cd build

cmake .. \
-DCMAKE_FIND_FRAMEWORK=LAST \
-DCMAKE_INSTALL_PREFIX=../build/macos/ \
-DRUN_IN_PLACE=FALSE -DENABLE_GETTEXT=TRUE

make -j$(sysctl -n hw.logicalcpu)
make install

# Apple Silicon (M1/M2) Macs w/ MacOS >= BigSur signature for local run
codesign --force --deep -s - --entitlements ../misc/macos/entitlements/debug.entitlements macos/luanti.app
```

If you are using LuaJIT with `MAP_JIT` support use `debug_map_jit.entitlements`.

### Run

```
open ./build/macos/luanti.app
```

## Building for distribution

### Generate Xcode project

```bash
mkdir build
cd build

cmake .. \
-DCMAKE_FIND_FRAMEWORK=LAST \
-DRUN_IN_PLACE=FALSE -DENABLE_GETTEXT=TRUE \
-DFREETYPE_LIBRARY=/path/to/lib/dir/libfreetype.a \
-DGETTEXT_INCLUDE_DIR=/path/to/include/dir \
-DGETTEXT_LIBRARY=/path/to/lib/dir/libintl.a \
-DLUA_LIBRARY=/path/to/lib/dir/libluajit-5.1.a \
-DOGG_LIBRARY=/path/to/lib/dir/libogg.a \
-DVORBIS_LIBRARY=/path/to/lib/dir/libvorbis.a \
-DVORBISFILE_LIBRARY=/path/to/lib/dir/libvorbisfile.a \
-DZSTD_LIBRARY=/path/to/lib/dir/libzstd.a \
-DGMP_LIBRARY=/path/to/lib/dir/libgmp.a \
-DJSON_LIBRARY=/path/to/lib/dir/libjsoncpp.a \
-DENABLE_LEVELDB=OFF \
-DENABLE_POSTGRESQL=OFF \
-DENABLE_REDIS=OFF \
-DJPEG_LIBRARY=/path/to/lib/dir/libjpeg.a \
-DPNG_LIBRARY=/path/to/lib/dir/libpng.a \
-DCMAKE_EXE_LINKER_FLAGS=-lbz2\
-GXcode
```

If you are using LuaJIT with `MAP_JIT` support add `-DXCODE_CODE_SIGN_ENTITLEMENTS=../misc/macos/entitlements/release_map_jit.entitlements`.

*WARNING:* You have to regenerate Xcode project if you switch commit, branch or etc.

### Build and Run

* Open generated Xcode project
* Select scheme `luanti`
* Configure signing Team etc.
* Run Build command
* Open application from `build/build/Debug/` directory or run it from Xcode

### Archive and Run

* Open generated Xcode project
* Select scheme `luanti`
* Configure signing Team etc.
* Run Build command
* Open application archive in finder, go into it, copy application and test it.
76 changes: 76 additions & 0 deletions content/for-engine-devs/compiling/windows_msvc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: Windows (Visual Studio / MSVC)
---

# Compiling on Windows using Visual Studio / MSVC

## Requirements

- [Visual Studio 2015 or newer](https://visualstudio.microsoft.com)
- [CMake](https://cmake.org/download/)
- [vcpkg](https://github.com/Microsoft/vcpkg)
- [Git](https://git-scm.com/downloads)


## Compiling and installing the dependencies

It is highly recommended to use vcpkg as package manager.

After you successfully built vcpkg you can easily install the required libraries:
```powershell
vcpkg install zlib zstd curl[winssl] openal-soft libvorbis libogg libjpeg-turbo sqlite3 freetype luajit gmp jsoncpp gettext[tools] sdl2 --triplet x64-windows
```

- `curl` is optional, but required to read the serverlist, `curl[winssl]` is required to use the content store.
- `openal-soft`, `libvorbis` and `libogg` are optional, but required to use sound.
- `luajit` is optional, it replaces the integrated Lua interpreter with a faster just-in-time interpreter.
- `gmp` and `jsoncpp` are optional, otherwise the bundled versions will be compiled
- `gettext` is optional, but required to use translations.

There are other optional libraries, but they are not tested if they can build and link correctly.

Use `--triplet` to specify the target triplet, e.g. `x64-windows` or `x86-windows`.


## Compile Luanti

### a) Using the vcpkg toolchain and CMake GUI

1. Start up the CMake GUI
2. Select **Browse Source...** and select DIR/luanti
3. Select **Browse Build...** and select DIR/luanti-build
4. Select **Configure**
5. Choose the right visual Studio version and target platform. It has to match the version of the installed dependencies
6. Choose **Specify toolchain file for cross-compiling**
7. Click **Next**
8. Select the vcpkg toolchain file e.g. `D:/vcpkg/scripts/buildsystems/vcpkg.cmake`
9. Click Finish
10. Wait until cmake have generated the cash file
11. If there are any errors, solve them and hit **Configure**
12. Click **Generate**
13. Click **Open Project**
14. Compile Luanti inside Visual studio.

### b) Using the vcpkg toolchain and the commandline

Run the following script in PowerShell:

```powershell
cmake . -G"Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CURSES=OFF
cmake --build . --config Release
```
Make sure that the right compiler is selected and the path to the vcpkg toolchain is correct.


## Windows Installer using WiX Toolset

Requirements:
* [Visual Studio 2017](https://visualstudio.microsoft.com/)
* [WiX Toolset](https://wixtoolset.org/)

In the Visual Studio 2017 Installer select **Optional Features -> WiX Toolset**.

Build the binaries as described above, but make sure you unselect `RUN_IN_PLACE`.

Open the generated project file with Visual Studio. Right-click **Package** and choose **Generate**.
It may take some minutes to generate the installer.
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
title: Compiling on Windows
title: Windows (MSYS2)
aliases:
- /compiling-on-windows-using-msys2/
- /compiling/windows-msys2/
- /compiling/windows
---

# Compiling on Windows
# Compiling on Windows using MSYS2

There are two ways to compile Luanti on a Windows machine: MSYS2 or a combination of vcpkg, cmake, and Visual Studio.

The simplest way to compile on Windows is with MSYS2. MSYS2 is a collection of tools and libraries providing you with an easy-to-use environment for building, installing and running native Windows software. This page lists how to compile Luanti on Windows using MSYS2.

Other documentation may recommend some combination of vcpkg, cmake, and Visual Studio. This is how the builds in the continuous integration pipeline are created, so they're more supported by the engine. However, they can be more difficult to setup. See [the engine docs on compiling for Windows](https://github.com/luanti-org/luanti/blob/master/doc/compiling/windows.md).
Other documentation may recommend some combination of vcpkg, cmake, and Visual
Studio. This is how the builds in the continuous integration pipeline are
created, so they're more supported by the engine.
See [Compiling on Windows using MSVC](../windows_msvc/).

This page focuses on MSYS2.

Expand Down
Loading