all groups > visual studio .net debugging > april 2006 >
You're in the

visual studio .net debugging

group:

VS2003 C++: multiply defined symbols linking errors... Help Please!



VS2003 C++: multiply defined symbols linking errors... Help Please! Gilbert Wu
4/12/2006 5:34:15 PM
visual studio .net debugging: Hi,

I am trying to debug a Win32 application written in C++ using VS2003 by =
another programmer who just left the company. The app compiled and run =
fine in Release mode. When I changed to Debug mode, the linker reported =
the following errors. Is there any attribute or directive I can set to =
avoid the mutliple symbol definitions? Your help would be much =
appreciated.

Many Thanks.

Regards,

Gilbert

nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator =
new(unsigned int)" (??2@YAPAXI@Z) already defined in =
LIBCMTD.lib(new.obj)

nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator =
delete(void *)" (??3@YAXPAX@Z) already defined in =
LIBCMTD.lib(dbgdel.obj)

nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator =
new[](unsigned int)" (??_U@YAPAXI@Z) already defined in =
LIBCMTD.lib(new2.obj)

nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator =
delete[](void *)" (??_V@YAXPAX@Z) already defined in =
LIBCMTD.lib(delete2.obj)

F:\GilbertDev\PriceServer\Visual Studio =
Projects\PriceFeeder\DataServerNew.exe : fatal error LNK1169: one or =
Re: VS2003 C++: multiply defined symbols linking errors... Help Please! Oleg Starodumov
4/13/2006 2:40:45 PM

[quoted text, click to view]

I don't know exactly what could cause it, but you can try to track it down.

Add /verbose option to the list of linker options. When linking, a long report
will be produced in the output window. This report will consist of many entries
similar to this:

Found "public: static void __stdcall CObject::operator delete(void *)" (??3CObject@@SGXPAX@Z)
Referenced in nafxcwd.lib(thrdcore.obj)
Referenced in nafxcwd.lib(afxinl1.obj)
Referenced in MyApp.obj
Loaded nafxcwd.lib(afxmem.obj)

It starts with the function name, then lists the object files that reference it,
and finally gives the library and object file where this function was found.

In this report, look up the place where libcmtd.lib(new.obj) was loaded.
Then use the "referenced" entries to find the object files that reference it.
I guess that the object file (and the corresponding source file) that references
code from new.obj and other reported .obj files is the one where you should
start looking for conflicting project settings.

If you are in a hurry, alternative way to debug this project is to disable optimizations
in Release build. It can be done using the following steps:
- In Configuration Manager, create new configuration and copy its settings
from Release configuration
- Disable C++ compiler optimizations (Project properties | Configuration properties |
C/C++ | Optimizations | "Optimization" = "Disabled (/Od)"
- Ensure that debug information is properly generated. The following options
should be present:
Compiler: /Zi
Linker: /debug
(they also can be set in the project settings)

After you have built the new configuration, you should be able to debug it
in the same way as a standard debug build. The only difference will be that
the application is linked with release MFC and CRT libraries, and their
debugging features (like tracing, assertions, etc.) will not be available.

Regards,
Oleg
[VC++ MVP http://www.debuginfo.com/]




AddThis Social Bookmark Button