My Music (Listen with quality headphones)

Sunday, 21 July 2013

LilyPond - how to make a simple screenshot of a musical phrase, following the LilyPond Learning Manual tutorial, in Ubuntu 13.04

Here's some info about my first attempt to use LilyPond in Ubuntu 13.04, by following the LilyPond Learning Manual (hereafter referred to as LLM).

Install LilyPond:
sudo apt-get install lilypond

To see the version that got installed, I ran this:
lilypond -v

which gave me this output:
GNU LilyPond 2.16.0

I created a test file here:

with the following code (taken directly from LMM):
\version "2.16.1"
  c' e' g' e'

Then I compiled the file:
cd /home/me/Library/Nickleus/music/lilypond/

which gave the following output:
GNU LilyPond 2.16.0
Processing `'
error: program too old: 2.16.0 (file requires: 2.16.1)
Interpreting music...
Preprocessing graphical objects...
Finding the ideal number of pages...
Fitting music on 1 page...
Drawing systems...
Layout output to `'...
Converting to `./test.pdf'...
fatal error: failed files: ""

I quickly found out that the error msgs were because the code from the LLM was not the same version as the lilypond that was installed, so to make the errors go away, I changed the code to this:
\version "2.16.0"
  c' e' g' e'

A pdf file was created here:

and it looks like this:

Then I wanted to find out how to create an image file instead. According to:
man lilypond

you export a png image like this:
lilypond --png

A png file was created here:

and it looks like this:

That's a pretty big image file. Here's how to make a cropped/compact version of the lilypond png output file so it shows just the sheetmusic/notes, without all the whitespace:
lilypond --png -dpreview

This creates the following files:

"eps" is a encapsulated postscript file.

The file I'm interested in is the test.preview.png file, because I'm looking for an easy and fast way to make screenshots of musical notation/sheet music for my tutorials. The file looks like this:

That's exactly what I wanted.

Download the LilyPond test file


Note: it seems that the code line about "version" is not strictly needed:
\version "2.16.0"

If you leave it out, then the lilypond compiler will just give you a warning:
... warning: no \version statement found, please add

\version "2.16.0"

for future compatibility


But as Glen points out in his comment below (and it's also recommended in the LLM):
it allows automatic updating of the input file as LilyPond syntax changes.


Here are some additional LilyPond resources:
Scores of Beauty: Aquatic Plants in Music – a blog about music engraving and LilyPond notation software
openLilyLib – tutorials
The Mutopia Project - lots of LilyPond files for classical pieces


  1. Specifying the version has 2 benefits: it prevents a warning and facilitates updating your source when you upgrade LilyPond to a newer version.

    Also, there are lots of LilyPond samples at

  2. Thanks Glen for the mutopia link, I'll update my tutorial, and good point about the automatic updating of the lilypond file :)


My content is under the Creative Commons Attribution 3.0 license. I work hard to publish relevant and useful information in order to help people learn difficult things and find solutions to their problems, so please attribute me if you reuse my content elsewhere.