15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Link Errors in VC 4.0

Mike Martonfi -- mikem@abelcomputers.com
Tuesday, February 13, 1996

When I upgraded my project from VC 2.2 to VC 4.0, I got the following link errors:

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(dbgnew.obj)
nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int,int,char const 
*,int)"(??2@YAPAXIHPBDH@Z) already defined in LIBCMTD.lib(dbgnew.obj)
WinDebug/abel.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

When I looked at the help for this message, it indicated that the most
common reason is the mixing of single-threaded and multi-threaded
libraries. But, in our case, this was not so.  I have checked my
run-time libraries for all of my objects and they all use "Debug
Multithreaded". So, to work around this problem, I tried excluding the
libraries NAFXCWD.LIB and LIBCMTD.LIB and including them again in the
"libraries to include" line. This made it work! The only thing that I
can come up with is that the project is dependent on the order of these
two libraries. Can anyone verify this or has anyone had similar
problems.



Charles Jowett -- jowett_charles@waters.com
Thursday, February 15, 1996

[Mini-digest: 2 responses]

Mike Martonfi wrote:
> 
> When I upgraded my project from VC 2.2 to VC 4.0, I got the following link errors:
> 
> 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(dbgnew.obj)
> nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int,int,char const
> *,int)"(??2@YAPAXIHPBDH@Z) already defined in LIBCMTD.lib(dbgnew.obj)
> WinDebug/abel.exe : fatal error LNK1169: one or more multiply defined symbols found
> Error executing link.exe.
> 
> When I looked at the help for this message, it indicated that the most
> common reason is the mixing of single-threaded and multi-threaded
> libraries. But, in our case, this was not so.  I have checked my
> run-time libraries for all of my objects and they all use "Debug
> Multithreaded". So, to work around this problem, I tried excluding the
> libraries NAFXCWD.LIB and LIBCMTD.LIB and including them again in the
> "libraries to include" line. This made it work! The only thing that I
> can come up with is that the project is dependent on the order of these
> two libraries. Can anyone verify this or has anyone had similar
> problems.

I had exactly the same problem (with the exact same error messages).  One of my co-workers posted
the question on Compuserve and received the following reply.  We tried it and it solved the problem.


The problem is the libraries are being linked in the wrong order.
To fix this do the following.  Go to the BUILD|SETTINGS menu and select WIN32 debug in the left pane 
of the dialog.  Now select the LINK tab.  Go to the INPUT catergory, and in the edit box that reads 
"Ignore Libraries:" type in NAFXCWD.LIB LIBCMTD.LIB
Now in the edit box that says "Object/Library Modules" put NAFXCWD.LIB LIBCMTD.LIB as the first two 
names (make sure they are in that order).  now select WIN32 Release in the right pane and do the same 
thing, except leave off the last D (i.e. use NAFXCW.LIB LIBCMT.LIB)

Charles
jowett_charles@waters.com
-----From: dhylands@creo.bc.ca

     I have experienced similar problems when using VC 2.0.
     
     Often adding the line:
     
        void* (*kludge)(size_t nSize) = operator new;
     
     will fix the problem. This causes the new function from MFC to be 
     linked in, rather than the one from the run time library.
     
Dave Hylands             Email: DHylands@creo.bc.ca   3700 Gilmore Way
Senior Software Developer  Tel: (604) 451-2700 x2329  Burnaby B.C.
Creo Products Inc.         Fax: (604) 437-9891        Canada V5G 4M1 




| Вернуться в корень Архива |