lovr/COMPILING.md

160 lines
4.2 KiB
Markdown
Raw Normal View History

2017-05-20 15:44:06 +00:00
Compiling LÖVR
===
You might want to compile LÖVR from source so you can use LÖVR on other operating systems or create
2017-05-20 15:47:19 +00:00
a custom build. Below is a guide for setting up all the dependencies and compiling the code on
various operating systems.
2017-05-20 15:44:06 +00:00
Dependencies
---
2017-07-30 01:56:08 +00:00
- Lua or LuaJIT
2017-05-20 15:44:06 +00:00
- GLFW (3.2+)
2017-06-19 00:45:14 +00:00
- OpenGL (3.3, ES3, or WebGL 2)
2017-05-20 15:44:06 +00:00
- assimp
2017-07-30 01:56:08 +00:00
- OpenVR (1.0.9, for `lovr.headset`)
2017-05-20 15:44:06 +00:00
- PhysicsFS
- OpenAL (1.17+ recommended for HRTF support)
- FreeType
2017-07-30 01:56:08 +00:00
- msdfgen
2017-06-19 00:45:14 +00:00
- ODE (for `lovr.physics`)
2017-05-20 15:44:06 +00:00
- Emscripten (optional, for compiling for web)
2017-08-14 01:45:42 +00:00
These can be found as submodules in the `deps` directory of the repository. To initialize the
submodules, clone LÖVR with the `--recursive` option or run this command in an existing repo:
2017-05-20 15:44:06 +00:00
```sh
2017-08-14 01:45:42 +00:00
git submodule update --init
2017-05-20 15:44:06 +00:00
```
2017-08-03 07:32:10 +00:00
Windows
2017-07-30 01:56:08 +00:00
---
From the `lovr` folder, run these commands to create a build folder and compile the project using
CMake:
2017-05-20 15:44:06 +00:00
```sh
mkdir build
cd build
cmake ..
cmake --build .
```
2017-07-30 01:56:08 +00:00
The executable will then exist at `/path/to/lovr/build/Debug/lovr.exe`. A LÖVR project (a folder
containing a `main.lua` script) can then be dropped onto `lovr.exe` to run it, or it can be run
via the command line as `lovr.exe path/to/project`.
2017-05-20 15:44:06 +00:00
2017-08-04 16:30:35 +00:00
macOS
2017-05-20 15:44:06 +00:00
---
2017-07-30 01:56:08 +00:00
Install the dependencies using your package manager of choice:
2017-05-20 15:44:06 +00:00
```sh
2017-07-05 23:25:31 +00:00
brew install assimp glfw3 luajit physfs freetype openal-soft ode
2017-05-20 15:44:06 +00:00
```
2017-07-30 01:56:08 +00:00
Next, build using CMake, as above:
2017-05-20 15:44:06 +00:00
```sh
mkdir build
cd build
2017-07-30 01:56:08 +00:00
cmake ..
2017-05-20 15:44:06 +00:00
cmake --build .
```
2017-07-30 01:56:08 +00:00
The `lovr` executable should exist in `lovr/build` now. It's recommended to set up an alias or
symlink so that this executable exists on your path. Once that's done, you can run a game like this:
2017-05-20 15:44:06 +00:00
```sh
2017-07-30 01:56:08 +00:00
lovr /path/to/myGame
2017-05-20 15:44:06 +00:00
```
2018-01-12 05:24:02 +00:00
You may need to set the `PKG_CONFIG_PATH` environment variable for OpenAL to be located properly.
If you run into this, see [Troubleshooting](#troubleshooting) below for more info.
2017-08-03 07:32:10 +00:00
Linux
---
First, install the dependencies using your package manager of choice.
#### Arch Linux
2017-08-03 07:32:10 +00:00
```sh
pacman -S assimp glfw-x11 luajit physfs freetype2 openal ode
```
#### Debian/Ubuntu
```sh
2017-10-18 04:51:50 +00:00
sudo apt-get install build-essential cmake libassimp-dev libglfw3-dev libluajit-5.1-dev libphysfs-dev libfreetype6-dev libopenal-dev libode-dev
```
2017-08-03 07:32:10 +00:00
Then, build with CMake:
```sh
mkdir build
cd build
cmake ..
cmake --build .
```
On Linux, LÖVR needs to run within the Steam Runtime. To do this, first [install
Steam](https://wiki.archlinux.org/index.php/Steam#Installation). Next, [install the Steam udev
rules](https://github.com/ValveSoftware/SteamVR-for-Linux#usb-device-requirements). Then, run LÖVR
within the Steam runtime:
```sh
~/.steam/steam/ubuntu12_32/steam-runtime/run.sh lovr
```
If you receive errors related to `libstdc++`, set the `LD_PRELOAD` environment variable when running
the command:
```sh
LD_PRELOAD='/usr/$LIB/libstdc++.so.6 /usr/$LIB/libgcc_s.so.1' ~/.steam/steam/ubuntu12_32/steam-runtime/run.sh lovr
```
2017-05-20 15:44:06 +00:00
WebVR
---
First, install the Emscripten SDK. Make sure you're running [this
branch](https://github.com/bjornbytes/emscripten/tree/lovr) of Emscripten.
Unix:
2017-05-20 15:44:06 +00:00
```sh
mkdir build
cd build
2018-01-02 05:28:53 +00:00
emcmake cmake ..
2017-05-20 15:44:06 +00:00
emmake make -j2
```
Windows (from a Visual Studio Command Prompt, make sure the Emscripten SDK is on PATH):
```sh
mkdir build
cd build
emcmake cmake -G "NMake Makefiles" ..
emmake nmake
```
2018-01-02 05:28:53 +00:00
The above commands will output `lovr.js` and `lovr.wasm`. To package a game, run:
2017-05-20 15:44:06 +00:00
```
2018-01-12 05:24:02 +00:00
python /path/to/emscripten/tools/file_packager.py game.data --no-heap-copy --preload /path/to/game@/ --js-output=game.js
2017-05-20 15:44:06 +00:00
```
2018-01-02 05:28:53 +00:00
Which will output `game.js` and `game.data`. You can then include `lovr.js` and `game.js` on an
HTML page with a canvas element. Check out [`lovr-webvr-server`](https://github.com/bjornbytes/lovr-webvr-server/blob/master/views/index.ejs) for an example.
2017-06-11 22:27:13 +00:00
Troubleshooting
---
- If you get "CMake no CMAKE_CXX_COMPILER found" on Windows, then install Visual Studio and create a
blank C++ project, which will prompt you to install the compilers and tools necessary to compile
LÖVR.
2017-09-06 06:01:15 +00:00
- On macOS, if you run into an error message about not being able to find OpenAL, make sure you've
added the proper OpenAL directory (usually something like
`/usr/local/opt/openal-soft/lib/pkgconfig`) to your `PKG_CONFIG_PATH` environment variable.
Installing openal-soft with brew will print out a message telling you how to do this.