When you compile a unit or program that needs other units, the compiler will look for compiled versions of these units in the following way:
You can add a directory to the unit search path with the (-Fu (see page 5.1.3)) option. Every occurrence of one of this options will insert a directory to the unit search path. i.e. the last path on the command line will be searched rst.
The compiler adds several paths to the unit search path:
/usr/local/lib/fpc/FPCVERSION
or /usr/lib/fpc/FPCVERSION |
whichever is found rst.
C:\FPC\1.9.6\units\i386-win32
|
This is assuming the compiler was installed in the directory
C:\FPC\1.9.6
|
After this directory is determined , the following paths are added to the search path:
Here target must be replaced by the name of the target you are compiling for: this is a combination of CPU and OS, so for instance
/usr/local/lib/fpc/1.9.6/units/i386-linux/
|
or, when cross-compiling
/usr/local/lib/fpc/1.9.6/units/i386-win32/
|
Note that (for optimization) the compiler will drop any non-existing paths from the search path, i.e. the existence of the path will be tested.
You can see what paths the compiler will search by giving the compiler the -vu option.
On systems where lenames are case sensitive (such as unix and linux), the compiler will :
This is necessary, since Pascal is case-independent, and the statements Uses Unit1; or uses unit1; should have the same e ect.
It will do this rst with the extension .pp and then with the extension .pas.
For instance, suppose that the le foo.pp needs the unit bar. Then the command
fpc -Fu.. -Fuunits foo.pp
|
will tell the compiler to look for the unit bar in the following places:
Also, unit names that are longer than 8 characters will rst be looked for with their full length. If the unit is not found with this name, the name will be truncated to 8 characters, and the compiler will look again in the same directories, but with the truncated name.
If the compiler nds the unit it needs, it will look for the source le of this unit in the same directory where it found the unit. If it nds the source of the unit, then it will compare the le times. If the source le was modi ed more recent than the unit le, the compiler will attempt to recompile the unit with this source le.
If the compiler doesn't nd a compiled version of the unit, or when the -B option is speci ed, then the compiler will look in the same manner for the unit source le, and attempt to recompile it.
It is recommended to set the unit search path in the con guration le fpc.cfg. If you do this, you don't need to specify the unit search path on the command-line every time you want to compile something.