2.1.1 Compiling a file

“Compiling” is the term used for processing an input file in LilyPond format to produce a file which can be printed and (optionally) a MIDI file which can be played. LilyPond input files are simple text files. The first example shows what a simple input file looks like.

To create sheet music, we write an input file that specifies the notation. For example, if we write:

{
  c' e' g' e'
}

the result looks like this:

[image of music]

Note: Notes and lyrics in LilyPond input must always be surrounded by { curly braces }. The braces should also be surrounded by a space unless they are at the beginning or end of a line to avoid ambiguities. The braces may be omitted in some examples in this manual, but don’t forget them in your own music! For more information about the display of examples in the manual, see How to read the manual.

In addition, LilyPond input is case sensitive. { c d e } is valid input; { C D E } will produce an error message.


Entering music and viewing output

In this section we will explain what commands to run and how to view or print the output.

Note that there are several other text editors available with better support for LilyPond. For more information, see Text editor support.

Note: The first time you ever run LilyPond, it may take a minute or two because all of the system fonts have to be analyzed first. After this, LilyPond will be much faster!

MacOS X

If you double click LilyPond.app, it will open with an example file. Save it, for example, to ‘test.ly’ on your Desktop, and then process it with the menu command Compile > Typeset File. The resulting PDF file will be displayed on your screen.

For future use of LilyPond, you should begin by selecting ‘New’ or ‘Open’. You must save your file before typesetting it. If any errors occur in processing, please see the log window.

Windows

On Windows, if you double-click in the LilyPond icon on the Desktop, it will open a simple text editor with an example file. Save it, for example, to ‘test.ly’ on your Desktop and then double-click on the file to process it (the file icon looks like a note). After some seconds, you will get a file ‘test.pdf’ on your desktop. Double-click on this PDF file to view the typeset score. An alternative method to process the ‘test.ly’ file is to drag and drop it onto the LilyPond icon using your mouse pointer.

To edit an existing ‘.ly’ file, right-click on it and select “Edit source”. To get an empty file to start from, run the editor as described above and use “New” in the “File” menu, or right-click on the desktop and select “New..Text Document”, change its name to a name of your choice and change the file extension to .ly. Double-click the icon to type in your LilyPond source code as before.

Double-clicking the file does not only result in a PDF file, but also produces a ‘.log’ file that contains some information on what LilyPond has done to the file. If any errors occur, please examine this file.

UNIX

Create a text file called ‘test.ly’ and enter:

{
  c' e' g' e'
}

To process ‘test.ly’, proceed as follows:

lilypond test.ly

You will see something resembling:

lilypond test.ly
GNU LilyPond 2.12.2
Processing `test.ly'
Parsing...
Interpreting music...
Preprocessing graphical objects...
Finding the ideal number of pages...
Fitting music on 1 page...
Drawing systems...
Layout output to `test.ps'...
Converting to `test.pdf'...

Other languages: français, español, deutsch.

Learning Manual