Running the Scenic Elixir GUI Framework on Windows 10 (using WSL)
By: Jeffrey Borchert
Tags: Windows Subsystem Linux, Windows 10, Elixir, GUI, Scenic

A native GUI framework for Elixir!? Boyd Multerer created this framework in 2018, but somehow I’ve missed it up until very recently. Excited to give it a try, I immediately went to the documentation to try and get the examples running… and found trouble.

Unfortunately for me and my school laptop, Scenic doesn’t have specific Windows support, with development focused mostly on GUIs for Linux and IOT applications using Nerves.

Now there is nothing about Scenic that is incompatible with a Windows environment so, with the right .dll dependencies and a custom Makefile, you can get it going. This is all a bit beyond me at the moment though, so I went with the easier option — Windows Subsystem for Linux.

It took a little research and several different sources to find a working setup, so, for your convenience, here are my consolidated instructions for running Scenic in WSL on Windows 10.

1. Enable WSL

First you need to enable Windows Subsystem for Linux in your Windows settings:

Go to Settings > Apps > Programs and Features

Click on Turn Windows features on or off on the sidebar

Find Windows Subsystem for Linux and make sure it is checked

2. Install Ubuntu

Now you need to find and install a Linux distribution. Just about any distribution will do, but we will use Ubuntu 18.04 (Bionic) here.

Go to the Microsoft Store and search for ‘Linux’

Choose the first Ubuntu from the list

Click on Install and wait for download to complete

Clicking on launch will open an Ubuntu bash terminal and begin installation

When prompted enter a new username and password for your Ubuntu account

3. Install X Server

You now have a working Linux command line, but WSL doesn’t include support for Linux graphical applications. We can fix that by installing an X Server application. VcXsrv and Xming both work great; we will use VcXsrv here.

Run the following commands in your Ubuntu terminal to install mesa-utils and OpenGL

sudo apt-get update sudo apt-get install mesa-utils

Find and download VcXsrv Windows X Server

Run the VcXsrv installer

When installer is complete, find and run XLaunch

Set the following config options:

Multiple Windows

Display number: 0

Start no client

Uncheck native OpenGL

Run the following command to set the display target

export DISPLAY=localhost:0

Run this command to check if Xserver and OpenGL are functioning properly. If you see the spinning gears, then all is well.

glxgears

4. Install Elixir and Erlang on Ubuntu

You will, of course, need to install Erlang OTP and Elixir in your Ubuntu file structure.

Run the following commands in your Ubuntu terminal:

wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb && sudo dpkg -i erlang-solutions_2.0_all.deb sudo apt-get update sudo apt-get install esl-erlang sudo apt-get install elixir

5. Install Make and gcc

Next you’ll need the gcc and Make utilities in order to build Scenic projects.

Run the following commands in your Ubuntu terminal:

sudo apt-get install make sudo apt-get install gcc

6. Install Scenic Dependencies

Scenic relies on the GLFW and GLEW libraries to connect to OpenGL, so these dependencies must be installed.

Run the following commands in your Ubuntu terminal:

sudo apt-get update sudo apt-get install pkgconf libglfw3 libglfw3-dev libglew2.0 libglew-dev

Finished!

And that’s it! You are now ready to follow along with the Getting Started section of the Scenic Documentation found here:

https://hexdocs.pm/scenic/getting_started.html

Once you’ve got the example working, I recommend you go and check out Giancarlo Franca’s excellent Snake Game tutorial:

https://blog.usejournal.com/elixir-scenic-snake-game-b8616b1d7ee0

Thank you and happy coding!