Setting up the environment
Although there are independent Wayland implementations such as Skylane and Sudbury, the reference implementation, libwayland-client, is by far the most popular. There are many libwayland-client bindings for different languages -- for example, Python, C++, Rust, Haskell, and even Objective-C (shameless plug) -- but in this book, we're going to use the vanilla C version.
Wayland is not technically limited to Linux and can be used on any Unix-like system, but to keep things simple we're going to be using Linux.
- First thing you're going to need is a working C compiler. I'm going to be using GCC, but you're welcome to replace it with Clang if you want to.
- Next, you'll need the wayland-client library. Your distro of choice likely has it in a package named
wayland
,libwayland-client
orlibwayland-client0
. And it's likely already installed. Awesome. - You're going to also need libwayland-client development files, in particular, the
wayland-client.h
header. It probably either comes with the package above or in a separate package such aswayland-devel
orlibwayland-dev
. - To run your program, you're going to need a working Wayland compositor. Major distros such as Arch, Fedora (since 25) and Ubuntu (since 17.10) are shipping with GNOME on Wayland by default, so if you're using one of those, everything should "just work" out of the box. Otherwise, the easiest way to get a Wayland compositor is to install Weston, the reference server implementation. You can run it on its own TTY or as a window under X. In the latter case, make sure to start your program from a terminal emulator running inside the compositor, so that it can pick up the necessary environment variables (or just set them manually).