Quick start manual
9-4
Delphi Language Guide
Writing dynamically loadable libraries
In this case, when importing routines, the shared object is not loaded until the code 
containing the call to dlopen executes. The shared object is later unloaded by the call 
to dlclose. This also allows you to conserve memory and to run your program even 
when some of the shared objects it uses are not present.
Writing dynamically loadable libraries
The main source for a dynamically loadable library is identical to that of a program, 
except that it begins with the reserved word library (instead of program).
Only routines that a library explicitly exports are available for importing by other 
libraries or programs. The following example shows a library with two exported 
functions, Min and Max.
library MinMax;
function Min(X, Y: Integer): Integer; stdcall;
begin
if X < Y then Min := X else Min := Y;
end;
function Max(X, Y: Integer): Integer; stdcall;
begin
if X > Y then Max := X else Max := Y;
end;
exports
Min,
Max;
begin
end.
If you want your library to be available to applications written in other languages, it’s 
safest to specify stdcall in the declarations of exported functions. Other languages 
may not support Delphi’s default register calling convention.
Note
If your application includes VisualCLX components, you must use packages instead 
of DLLs or shared objects. Only packages can manage the startup and shutdown of 
the Qt shared libraries.










