$LINKLIB : Link to a library

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

#### 1.2.46 $LINKLIB : Link to a library

The {$LINKLIB name} will link to a library name. This has the effect of passing -lname to the linker.

As an example, consider the following unit:

unit getlen;
interface
{$LINKLIB c}
function strlen (P : pchar) : longint;cdecl;
implementation
function strlen (P : pchar) : longint;cdecl;external;
end.

If one would issue the command

ppc386 foo.pp

where foo.pp has the above unit in its uses clause, then the compiler would link the program to the c library, by passing the linker the -lc option.

The same can be obtained by removing the linklib directive in the above unit, and specify -k-lc on the command line:

ppc386 -k-lc foo.pp

Note that the linker will look for the library in the linker library search path: one should never specify a complete path to the library. The linker library search path can be set with the -Fl command line option.

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