[next] [prev] [prev-tail] [tail] [up]

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

Remark: Under L I N U X and U N I X, a unit source file must have a lowercase filename. Since Pascal is case independent, you can specify the names of units in the uses clause in either case. To get a unique filename, the Free Pascal compiler changes the name of the unit to all lowercase when looking for unit files. The compiler produces lowercase files, so your unit will be found, even if your source file has uppercase letters in it. Only when the compiler tries to recompile the unit, it will not find your source because of the uppercase letters.

[next] [prev] [prev-tail] [front] [up]