Next: Building DLLs with GNAT, Previous: Introduction to Dynamic Link Libraries (DLLs), Up: Microsoft Windows Topics
To use the services of a DLL, say API.dll, in your Ada application you must have:
Once you have all the above, to compile an Ada application that uses the
services of API.dll and whose main subprogram is My_Ada_App
,
you simply issue the command
$ gnatmake my_ada_app -largs -lAPI
The argument -largs -lAPI at the end of the gnatmake
command
tells the GNAT linker to look first for a library named API.lib
(Microsoft-style name) and if not found for a library named libAPI.a
(GNAT-style name). Note that if the Ada package spec for API.dll
contains the following pragma
pragma Linker_Options ("-lAPI");
you do not have to add -largs -lAPI at the end of the gnatmake
command.
If any one of the items above is missing you will have to create it yourself. The following sections explain how to do so using as an example a fictitious DLL called API.dll.