3.3 Compiling a unit

Compiling a unit is not essentially different from compiling a program. The difference is mainly that the linker isn’t called in this case.

To compile a unit in the file foo.pp, just type :

  fpc  foo

Recall the remark about file extensions in the previous section.

When all went well, you will be left with 2 (two) unit files:

1.
foo.ppu - this is the file describing the unit you just compiled.
2.
foo.o - this file contains the actual code of the unit. This file will eventually end up in the executables.

Both files are needed if you plan to use the unit for some programs. So don’t delete them. If you want to distribute the unit, you must provide both the .ppu and .o file. One is useless without the other.