Creating a Single Import Library for Multiple DLLsLast reviewed: July 22, 1997Article ID: Q68081 |
3.00 3.10
WINDOWS
kbprg
The information in this article applies to:
SUMMARYA single import library that contains information about multiple dynamic-link libraries (DLLs) can sometimes be useful. One example in the Microsoft Windows graphical environment is LIBW.LIB, which serves as the single import library through which an application can link to the Windows system DLLs GDI.DLL, KERNEL.DLL, and USER.DLL. An import library for many DLLs can be created by supplying multiple module definition (DEF) files as input parameters to the IMPLIB utility. However, one must make sure that none of the exported functions is defined in more than one DEF file. IMPLIB issues an error message when a function name is defined more than once, which occurs most often with the Windows exit procedure (WEP) because each DLL must export its own WEP in its DEF file. To avoid an IMPLIB error indicating that the WEP routine is defined many times, create modified DEF files that do not contain EXPORT statements for the WEP routine and specify these files as input to IMPLIB.
MORE INFORMATIONDefining a function in an import library more than once creates an ambiguity when the loader resolves references to functions exported by other modules. For example, suppose two DLLs that share a common import library export an Open function. When an application refers to a function in a DLL, the loader resolves a reference to the function (known as a fix-up) to its true address (which is not known until run time). The DLL containing the function must be loaded to provide a true address for its functions. However, in this example, this poses a dilemma: because both DLLs contain an Open function, which one should be used? Because the application's source code makes no distinction between the two Open functions, the loader cannot resolve the reference correctly. To avoid the potential for ambiguity, IMPLIB issues an error message for each function that is defined in multiple DEF files and does not create a combined import library. Two DLLs that share a common function name cannot share a single import library. The one exception to this rule is the WEP function, which every DLL must export. Because an application does not call the WEP, the function need not be listed in the combined import library. To create a single import library, MYIMPLIB.LIB, that can be used to link to the three DLLs (DLL1, DLL2, and DLL3), perform the following four steps in this order:
A dummy DEF file must not be used to link a DLL because a dummy DEF file does not export the WEP function. Every DLL must export a WEP that Windows can call before removing the DLL from memory.
|
Additional reference words: 3.00 3.10
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |