Using a DLL

When an application is to use functions contained in a DLL, these functions must first be declared at compilation time. This is typically achieved by the use of an include file containing function prototypes for all exportable entry points within the DLL; such an include file is normally created along with the DLL and supplied to all application developers who will use the DLL.

Once the functions are declared within the application's source code, the external references must be resolved at the time the program is link edited. This may be performed in one of two ways:

  • The functions may be identified in the application's module definition file using an IMPORTS statement, as described in Module Definition File. For example, the statement:
    IMPORTS MYPROG.func1
    

    defines the function func1, which will be imported from a DLL named MYPROG.DLL.

  • The functions may be included in an import library, which is a library specified at link edit time. An import library is created using the IMPLIB utility provided with the IBM Developer's Toolkit for OS/2 2.0. For example, the command:
    implib MYLIB.LIB MYLIB.DEF
    

    causes IMPLIB to create an import library named MYLIB.LIB, using information contained in a module definition file named MYLIB.DEF. The import library file should be placed in a directory referenced by the INCLUDE environment variable.

    Note that the file OS2.LIB, used when link editing OS/2 application programs, is in fact an import library containing definitions for OS/2 system functions that are themselves implemented using DLLs.


    [Back: Creating a DLL]
    [Next: Presentation Manager Resources in a DLL]