[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1253
  • Last Modified:

DLL Problem

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
pcssecure
Asked:
pcssecure
  • 3
1 Solution
 
sunnycoderCommented:
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
 
wesbirdCommented:
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
 
wesbirdCommented:
did it work?  I really need the points this month?
0
 
wesbirdCommented:
looks like the split didn't work!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now