Please Help! - Link Error LNK2005 
Author Message
 Please Help! - Link Error LNK2005

Hi,
I am using Visual C++ v6.0 (with Visual Studio SP3 on WinNT 4 SP5) and
cannot resolve a link error when compiling a Window's app.

The error appears to reflect a conflict between the MFC and C++
libraries.  However, I am at a loss on how to solve it.

Can anyone offer some help?  The build error is shown below.
Thanks,
David Faltermier
========
Linking...

nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator

nafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator

.\Release/DOA.exe : fatal error LNK1169: one or more multiply defined
symbols found

Error executing link.exe.

DOA.exe - 3 error(s), 0 warning(s)
========



Fri, 05 Jul 2002 03:00:00 GMT  
 Please Help! - Link Error LNK2005
Hi,

I am using Visual C++ v6.0 (with Visual Studio SP3 on WinNT 4 SP5) and
cannot resolve a link error when compiling a Window's app.

The error appears to reflect a conflict between the MFC and C++
libraries.  However, I am at a loss on how to solve it.

Can anyone offer some help?  The build error is shown below.
Thanks,
David Faltermier
========
Linking...

nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator

nafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator

.\Release/DOA.exe : fatal error

LNK1169: one or more multiply defined symbols found

Error executing link.exe.

DOA.exe - 3 error(s), 0 warning(s)
========



Fri, 05 Jul 2002 03:00:00 GMT  
 Please Help! - Link Error LNK2005

Goto Project Settings | Link tab | Category "Input"
    Ignore Libraries: libcmt.lib

Let me know if this worked...

-Krishna 'Kotpal'

    Hi,
    I am using Visual C++ v6.0 (with Visual Studio SP3 on WinNT 4 SP5) and cannot resolve a link error when compiling a Window's app.
    The error appears to reflect a conflict between the MFC and C++ libraries.  However, I am at a loss on how to solve it.

    Can anyone offer some help?  The build error is shown below.
    Thanks,
    David Faltermier
    ========
    Linking...



    .\Release/DOA.exe : fatal error LNK1169: one or more multiply defined symbols found

    Error executing link.exe.

    DOA.exe - 3 error(s), 0 warning(s)
    ========



Fri, 05 Jul 2002 03:00:00 GMT  
 Please Help! - Link Error LNK2005

Hi Kotpal,

Thanks for the advice but I had tried this before.  If I ignore either
libcmt.lib or nafxcw.lib, I get tons of "error LNK2001: unresolved
external symbol" errors.  This can't be the right approach.

I've gone to Help | search tab and typed "lnk2005".  It provides the
below help but I'm not sure what I would need to change.
-David Faltermier

==========================================
Linker Tools Error LNK2005: symbol already defined in object
The given symbol, displayed in its decorated form, was multiply defined.

One of the following may be a cause:

1. The most common cause of this error is accidentally linking with both
the single-threaded and multithreaded libraries. Ensure that the
application project file includes only the appropriate libraries and
that any third-party libraries have appropriately created
single-threaded or multithreaded versions.

2. The given symbol was a packaged function (created by compiling with
/Gy) and was included in more than one file but was changed between
compilations. Recompile all files that include the symbol.

3. The given symbol was defined differently in two member objects in
different libraries, and both member objects were used.

4. An absolute was defined twice, with a different value in each
definition.
=================================================

Quote:

>  Goto Project Settings | Link tab | Category "Input"    Ignore
> Libraries: libcmt.lib Let me know if this worked... -Krishna 'Kotpal'



>      I am using Visual C++ v6.0 (with Visual Studio SP3 on WinNT
>      4 SP5) and cannot resolve a link error when compiling a
>      Window's app.

>      The error appears to reflect a conflict between the MFC and
>      C++ libraries.  However, I am at a loss on how to solve it.

>      Can anyone offer some help?  The build error is shown below.

>      Thanks,
>      David Faltermier
>      ========
>      Linking...

>      nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl

>      in LIBCMT.lib(new.obj)

>      nafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl

>      LIBCMT.lib(delete.obj)

>      .\Release/DOA.exe : fatal error LNK1169: one or more
>      multiply defined symbols found

>      Error executing link.exe.

>      DOA.exe - 3 error(s), 0 warning(s)
>      ========



Fri, 05 Jul 2002 03:00:00 GMT  
 Please Help! - Link Error LNK2005
The conflict is between the static MFC library and the static multi-threaded C
Runtime library.  That's all I can tell you for sure.

p.s., I never link to the static libs -- in fact, I didn't even install them.
IMO, using the DLLs is always the better route.



Fri, 05 Jul 2002 03:00:00 GMT  
 Please Help! - Link Error LNK2005
I think the problem is that by default, these two libraries are
linked in in the wrong order.  You need to force them to be linked
in the right order by entering them in the linker "ignore" field,
then entering them in the correct order in the "object/library modules"
field (I think you should have nafxcw.lib first, then libcmt.lib).

- Dave

Quote:

> Hi,
> I am using Visual C++ v6.0 (with Visual Studio SP3 on WinNT 4 SP5) and
> cannot resolve a link error when compiling a Window's app.

> The error appears to reflect a conflict between the MFC and C++
> libraries.  However, I am at a loss on how to solve it.

> Can anyone offer some help?  The build error is shown below.
> Thanks,
> David Faltermier
> ========
> Linking...

> nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator

> LIBCMT.lib(new.obj)

> nafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator

> LIBCMT.lib(delete.obj)

> .\Release/DOA.exe : fatal error LNK1169: one or more multiply defined
> symbols found

> Error executing link.exe.

> DOA.exe - 3 error(s), 0 warning(s)
> ========



Sat, 06 Jul 2002 03:00:00 GMT  
 Please Help! - Link Error LNK2005
Dave (Clark),

You're right!  I made the changes you suggested and it compiled/linked
perfectly.

(First, specifying the linker to ignore the nafxcw.lib and libcmt.lib
libraries, then adding them back into the "object/library modules" in
the order "nafxcw.lib libcmt.lib.")

Thanks for your help, Dave!
-David (Faltermier)



Sat, 06 Jul 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Please Help! - Link Error LNK2005

2. help- Link error LNK2005

3. PRB: LNK2005 Errors When Link C Run-Time Libraries Are Linked Before MFC Libraries (Q148652)

4. Link Errors : error LNK2005 and LNK2004

5. LNK2005 Link errors when doing Release Build??

6. link problem, error LNK2005 using CSocket

7. LNK2005 Link errors when doing Release Build??

8. Link error (LNK2005) - Any suggestions

9. Please help, ATL with MFC support Link error

10. _cdecl confusion, link error, Please Help

11. Link error L5000 with MSC - Please help

12. Linking error, someone help me please

 

 
Powered by phpBB® Forum Software