3.2 Compiling a program

Compiling a program is very simple. Assuming that you have a program source in the file prog.pp, you can compile this with the following command:

  fpc [options] prog.pp

The square brackets [ ] indicate that what is between them is optional.

If your program file has the .pp or .pas extension, you can omit this on the command line, e.g. in the previous example you could have typed:

  fpc [options] prog

If all went well, the compiler will produce an executable file. You can execute it straight away; you don’t need to do anything else.

You will notice that there is also another file in your directory, with extension .o. This contains the object file for your program. If you compiled a program, you can delete the object file (.o), but don’t delete it if you compiled a unit. This is because the unit object file contains the code of the unit, and will be linked in any program that uses it.