Next: , Up: First steps


2.1.1 Compiling a file

The first example demonstrates how to start working with LilyPond. To create sheet music, we write a text file that specifies the notation. For example, if we write

{
  c' e' g' e'
}

the result looks like this

[image of music]

Warning: Every piece of LilyPond input needs to have { curly braces } placed around the input. The braces should also be surrounded by a space unless they are at the beginning or end of a line to avoid ambiguities. These may be omitted in some examples in this manual, but don't forget them in your own music!

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.

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.

Be warned that the first time you ever run LilyPond, it will take a minute or two because all of the system fonts have to be analyzed first.

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, start up a text-editor1 and enter

{
  c' e' g' e'
}

Save it on the desktop as test.ly and make sure that it is not called test.ly.TXT. Double clicking test.ly will process the file and show the resulting PDF file. To edit an existing .ly file, right-click on it and select “Edit source”.

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. 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.

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

Begin by opening a terminal window and starting a text editor. For example, you could open an xterm and execute joe2. In your text editor, enter the following input and save the file as test.ly

{
  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.10.0
Processing `test.ly'
Parsing...
Interpreting music... [1]
Preprocessing graphical objects...
Calculating line breaks... [2]
Layout output to `test.ps'...
Converting to `test.pdf'...

The result is the file test.pdf which you can print or view with the standard facilities of your operating system.3


Footnotes

[1] Any simple or programmer-oriented editor with UTF-8 support will do, for example Notepad. Do not use a word processor, since these insert formatting codes that will confuse LilyPond.

[2] There are macro files for VIM addicts, and there is a LilyPond-mode for Emacs addicts. If they have not been installed already, refer to the file INSTALL.txt. The easiest editing environment is LilyPondTool. See Editor support for more information.

[3] If your system does not have any such tools installed, you can try Ghostscript, a freely available package for viewing and printing PDF and PostScript files.


Next: , Up: First steps

This page is for LilyPond-2.10.33 (stable-branch).

Report errors to http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.

Other languages: French.