next up previous contents
Next: Using external functions or Up: Free Pascal programmers guide Previous: Register Conventions

Linking issues

  When you only use Pascal code, and Pascal units, then you will not see much of the part that the linker plays in creating your executable. The linker is only called when you compile a program. When compiling units, the linker isn't invoked.

However, there are times that you want to C libraries, or to external object files that are generated using a C compiler (or even another pascal compiler). The Free Pascal compiler can generate calls to a C function, and can generate functions that can be called from C (exported functions). More on these calling conventions can be found in section (3.3).

In general, there are 2 things you must do to use a function that resides in an external library or object file:

  1. You must make a pascal declaration of the function or procedure you want to use.
  2. You must tell the compiler where the function resides, i.e. in what object file or what library, so the compiler can link the necessary code in.
The same holds for variables. To access a variable that resides in an external object file, you ust declare it, and tell the compiler where to find it. The following sections attempt to explain how to do this.





Michael Van Canneyt
Thu Sep 10 14:04:11 CEST 1998