12.5 Libraries

Free Pascal supports making of dynamic libraries (DLLs under Win32 and os/2) trough the use of the Library keyword.

A Library is just like a unit or a program:

_________________________________________________________________________________________________________ Libraries
-- --library- library header- ;--------------block -.---------------------
                           -uses clause-|

-- --           -      -       -------------------------------------
     library header library  identi  er
___________________________________________________________________

By default, functions and procedures that are declared and implemented in library are not available to a programmer that wishes to use this library.

In order to make functions or procedures available from the library, they must be exported in an export clause:

_________________________________________________________________________________________________________ Exports clause
-- --exports clause exports-exports list ;------------------------------

-- --exports list|exports entry----------------------------------------
               6-----,-------

-- exports entry-identi  er---------------------------------------------
                        -index -integer constant-| -name -string constant-|
- -----------------------------------------------------------------
___________________________________________________________________

Under Win32, an index clause can be added to an exports entry. an index entry must be a positive number larger or equal than 1.

Optionally, an exports entry can have a name specier. If present, the name specier gives the exact name (case sensitive) of the function in the library.

If neither of these constructs is present, the functions or procedures are exported with the exact names as specied in the exports clause.