?
Solved

DLL Problem

Posted on 2004-09-09
6
Medium Priority
?
1,228 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 2000 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

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops 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.
Suggested Courses

771 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