CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2006
    Posts
    29

    Link Error _DllMain@12 already defined

    Here's the situation:

    I have a VS 2005 project and 'Use of MFC' is set as [Use Windows Standard Libraries]. This project generates a DLL

    When compiling, I am getting the following link errors

    Code:
    1>uafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MyDLL.obj
    1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)
    1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj)
    1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmtd.lib(newaop.obj)
    1>uafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCMTD.lib(delete2.obj)
    I don't understand why the project is linking with uafxcwd.lib

    Any idea?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

  3. #3
    Join Date
    May 2006
    Posts
    29

    Re: Link Error _DllMain@12 already defined

    I've been to that link already and tried the fixes but the following error still exists

    Code:
    1>uafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MyDLL.obj
    What puzzles me here is that, my DLL is set as a Standard Windows Library (non MFC), it should not link to uafxcwd.lib (an MFC library).. am I correct?

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Link Error _DllMain@12 already defined

    It depends on actual code inclusions. In case some part of your code "touches" MFC stuff, you just cannot avoid the dependency. And make sure your project has no "AFX" defines.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured