Skip to content

Build for Raspberry Pi

Mariotaku edited this page May 9, 2021 · 4 revisions

Build Moonlight

Checkout sources, and run ./scripts/raspi/easy_build.sh. There will be a deb package available for installation.

Run Without Desktop Environment

Moonlight should be able to pick available video driver automatically, but on different models, you may need to do some extra work. For example, on Pi 4B model, rpi video driver simply does not work. According to this thread, using kmsdrm is a better choice.

However, according to SDL version you are using, it may not contain kmsdrm (2.0.9 on buster). You can grab sources from a newer release, build deb package and install them instead. This should be the cleanest solution, because:

  1. It keeps changes to your system minimum and consistent.
  2. When you do a release upgrade in the future, newer version will replace this one seamlessly.
  3. When you want to uninstall it, what you need is just an apt-get remove command.

Add testing Sources

# echo 'deb-src http://deb.debian.org/debian/ testing main' > /etc/apt/sources.list.d/testing-sources.list
# apt-get update

If you see NO_PUBKEY error, copy those hexadecimal keys and trust them:

# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys PUBKEYS_FROM_ABOVE
# apt-get update

Get libsdl2 sources

Run following commands in your working directory

$ apt-get source libsdl2

Build libsdl2

cd to the directory of extract sources (e.g. libsdl2-2.0.14+dfsg2) and run dpkg-buildsource. You will need to install dpkg-dev and many dependencies mentioned during this process.

You may get following error while building libsdl2 from source:

.../libsdl2-2.0.14+dfsg2/src/video/kmsdrm/SDL_kmsdrmvideo.c: In function ‘KMSDRM_CreateWindow’:
.../libsdl2-2.0.14+dfsg2/src/video/kmsdrm/SDL_kmsdrmvideo.c:1765:71: error: ‘EGL_PLATFORM_GBM_MESA’ undeclared (first use in this function); did you mean ‘VK_PLATFORM_H_’?
              if ((ret = SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA))) {
                                                                       ^~~~~~~~~~~~~~~~~~~~~
                                                                       VK_PLATFORM_H_

This is because EGL_PLATFORM_GBM_MESA is not defined. According to this commit from SDL, you can add following lines to src/video/kmsdrm/SDL_kmsdrmvideo.c, after first batch of #defines.

#ifndef EGL_PLATFORM_GBM_MESA
#define EGL_PLATFORM_GBM_MESA 0x31D7
#endif

Then, execute dpkg-source --commit to commit your changes.

You may need to describe your changes, but since it's just your own local build, anything should be fine.

If done correctly, few deb packages will be generated in parent directory. What you need is libsdl2-2.0-0_[version]_armhf.deb and libsdl2-dev_[version]_armhf.deb. Install them and Moonlight should be able to start now.

Open Wiki on your phone

moonlight-tv Wiki

Clone this wiki locally