PRB: Extra Copies of Function Added to LibraryLast reviewed: July 25, 1997Article ID: Q113065 |
The information in this article applies to:
SYMPTOMSIf a function is contained in a library being added to another library, and that function already exists in the library being added to, LIB.EXE adds it anyway. The following warning is generated:
LNK4006: <function name> already defined in <library name> <object module name>; second definition ignoredThe .OBJ file is added to the library, and can be added multiple times.
CAUSEThis behavior is by design.
RESOLUTIONIf you add an object module that is already in the library, the new object module replaces the old one. However, if you combine libraries, they are always combined because there could be similarly named object modules in several different libraries that don't have any of the same functions. The above warning is generated to indicate conflicting function names. MORE INFORMATION Examining the contents of the library with the DUMPBIN utility
DUMPBIN <library name> /symbolsshows multiple copies of the function exist in the library. The DUMPBIN utility is in the \MSVCNT\BIN directory.
Sample Code
/* FILE A.C Compile options needed: /c */ #include <stdio.h> void amain(void) { printf("a"); } /* FILE B.C Compile options needed: /c */ #include <stdio.h> void bmain(void) { printf("b"); } /* Lib commands needed: */ /* Create the libraries TEST.LIB and TESTB.LIB */ lib /out:test.lib a.obj lib /out:testb.lib b.obj /* Add the contents of TESTB.LIB (B.OBJ) to TEST.LIB: */ lib test.lib testb.lib /* List the current contents of TEST.LIB; */ /* it will show one copy of A.OBJ and one copy of B.OBJ. */ lib test.lib /list /* Add the contents of TESTB.LIB (B.OBJ) to TEST.LIB again. */ /* This step generates the above warning. */ lib test.lib testb.lib /* List the current contents of TEST.LIB; */ /* it will show two copies of B.OBJ in the library. */ lib test.lib /list Keywords : LibIss Version : 1.0 2.0 5.0 Issue type : kbprb |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |