Solved

DLL Problem

Posted on 2004-09-09
6
1,218 Views
Last Modified: 2012-06-22
Hi,
   I am writing a DLL A that uses another DLL B. I get the following error when trying to compile DLL A,

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

What is the most likely cause of this error? And how can I solve this?

Please advise.

Thanks.
0
Comment
Question by:pcssecure
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 500 total points
ID: 12014792
Not into windows or DLLs but this is a linking problem occuring due to redefinition ... Here's what I could find

from www.differentpla.net/node/view/251


Everyone knows that mixing up files compiled for multithreaded, multithreaded DLL and single threaded is a recipe for having multiple symbol definitions. However it's not the only way to produce very similar looking symptoms and Google isn't much help in that situation.


Linking...
uafxcw.lib(afxmem.obj) : error LNK2005:
"void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in libcpmt.lib(newop.obj)
uafxcw.lib(afxmem.obj) : error LNK2005:
"void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmt.lib(newaop.obj)
ReleaseUS/widget.exe : fatal error LNK1169:
one or more multiply defined symbols found



Linking...
nafxcw.lib(afxmem.obj) : error LNK2005:
"void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in libcpmt.lib(newop.obj)
nafxcw.lib(afxmem.obj) : error LNK2005:
"void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmt.lib(newaop.obj)
./ReleaseS/doodah.exe : fatal error LNK1169:
one or more multiply defined symbols found


Getting error messages like these when linking MFC code using Visual Studio is not uncommon; the instinctive reaction is to reach for the "Code Generation" settings for the various projects being linked and check the runtime library (in Visual Studio.NET 2003 this is under Project Configuration Properties, C/C++, Code Generation, Runtime Library). A good trick at this point is to select all your projects and see if the field value goes blank, if it doesn't then the settings are consistent.

But, to return to the point, what if you know that everything is correct and you've spent four hours banging your head against a brick wall trying to make it link? The debug builds are fine, it's just the release builds that fail. The cause would appear to be including <new> before <afx.h>. Of course it is unlikely that you've actually done this explicitly but you might just be including something that includes <new> as a side-effect such as <algorithm>. It would appear that you have to do other things in addition to this to cause the link failure but removing the inclusion of <new> certainly seems to solve the problem.
0
 
LVL 7

Expert Comment

by:wesbird
ID: 12020010
Try this: http://support.microsoft.com/default.aspx?scid=kb;en-us;148652

I've been there before.  It is worth taking time to read this and may take a few trys before it works, but it will eventually :-)

Wes
0
 
LVL 7

Expert Comment

by:wesbird
ID: 12417197
did it work?  I really need the points this month?
0
 
LVL 7

Expert Comment

by:wesbird
ID: 12910205
looks like the split didn't work!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question