To link your program to a library, the procedure depends on how you declared the external procedure. If you used thediffers a little from the procedure when you link in an object file. although the declaration step remains the same (see 4.1 on how to do that).
In case you used the follwing syntax to declare your procedure:
Procedure ProcName (Args : TPRocArgs); external 'Name';You don't need to take additional steps to link your file in, the compiler will do all that is needed for you.
In case you used
Procedure ProcName (Args : TPRocArgs); external;You still need to explicity link to the library. This can be done in 2 ways:
{$LinkLib 'gpm'}This will link to the gpm library. On LINUX systems, you needn't specify the extension or 'lib' prefix of the library. The compiler takes care of that. On DOS or systems, you need to specify the full name.
ppc386 -k'-lgpm' myprog.ppIs equivalent to the above method, and tells the linker to link to the gpm library.
As an example; consider the following program :
program printlength; {$linklib c} { Case sensitive } { Declaration for the standard C function strlen } Function strlen (P : pchar) : longint; cdecl;external; begin Writeln (strlen('Programming is easy !')); end.This program can be compiled with :
pp prlen.ppSupposing, of course, that the program source resides in prlen.pp.
You cannot use procedures or functions that have a variable number of arguments in C. Pascal doesn't support this feature of C.