Solved

DLL Problem

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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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 opening and writing to files in the C programming language.
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.

828 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