Microsoft KB Archive/113065

= PRB: Extra Copies of Function Added to Library =

Article ID: 113065

Article Last Modified on 12/1/2003

-

APPLIES TO

 The Library Manager (LIB.EXE), when used with:  Microsoft Visual C++ 1.0 Professional Edition

 Microsoft Visual C++ 2.0 Professional Edition

 Microsoft Visual C++ 5.0 Standard Edition 

-

<div class="notice_section">

This article was previously published under Q113065

<div class="symptoms_section">

SYMPTOMS
If 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: already defined in ; second definition ignored

The .OBJ file is added to the library, and can be added multiple times.

<div class="cause_section">

CAUSE
This behavior is by design.

<div class="resolution_section">

RESOLUTION
If 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.

<div class="moreinformation_section">

MORE INFORMATION
Examining the contents of the library with the DUMPBIN utility <pre class="fixed_text">  DUMPBIN /symbols shows 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

void amain(void) {   printf("a"); }
 * 1) include <stdio.h>

/* FILE B.C  Compile options needed: /c

void bmain(void) {   printf("b"); }
 * 1) include <stdio.h>

/* 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: kbprb KB113065

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.