Solved

DLL Problem

Posted on 2004-09-09
6
1,179 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now