Developing with Fyne


Start developing your own apps with the Fyne toolkit

Compiling a Fyne application


Although Fyne has no native dependencies and is a pure Go API it does require CGo for calling system graphics libraries. Because of this you will need a C compiler (typically gcc, clang or compatible).

Installing a C compiler

Most developer systems will already have one installed, but if you are getting started or have not used a C compiler before this section should get you set up.

Linux

On Linux the “gcc” package may already be installed - if not then install this from your package manager. One of the following commands is likely to work for your system:

If this works then you will be able to run gcc --version to see that it’s installed and on your PATH.

macOS

On macOS you should install XCode from the Mac App Store - first check you are on a fast internet connection as it is a large download. Once downloaded you will need to run xcode-select --install to set up the command line tools (if you have not used them before). It is not unusual to find that your command line tools stop working after an Operating System upgrade - if this occurs simply execute that command again.

Windows

Windows does not have a standard way to install a C compiler, but there are many options available. Some that have worked for contributors of this project are:

Dependencies

By default Fyne uses the gl and GLFW bindings for Go which means that OpenGL must be installed on the development, and runtime, systems. Most modern desktop platforms have this running out of the box so this should not be a problem. On some Linux systems, however, the files needed to compile with OpenGL are not included. Here is a list of the packages you may need to install for various distributions:

Distribution Packages required
Debian/Ubuntu libgl1-mesa-dev and xorg-dev
Fedora libXcursor-devel libXrandr-devel mesa-libGL-devel libXi-devel

Compiling

Once the installation and setup is complete you can compile a fyne application like any other Go code:

go run main.go

or

go build
./main

Summary


In this page we explored how to compile a Fyne application. Although compiling using the Go tools is usually very simple the Fyne toolkit uses Cgo which can add complications. By installing a C compiler as described above you will be able to build your Fyne application just like a normal Go program.

Get In Touch!


We're excited to hear from anyone interested in the project. Whether it's to find out more, provide suggestions or to get involved - drop us a line!

If you would like to join us on slack but are not yet signed up to the golang slack server you can request an invite.