CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old January 27th, 2000, 07:09 AM
    Guest
     
    Posts: n/a
    _DllMain@12 already defined error

    How to avoid the the following error:


    mfcs42d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in mydll.obj
    fcs42d.lib(dllmodul.obj) : error LNK2005: __pRawDllMain already defined in mydll.obj
    mfcs42d.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in mydll.obj; second definition ignored
    mfcs42d.lib(dllmodul.obj) : warning LNK4006: __pRawDllMain already defined in mydll.obj; second definition ignored
    Creating library \Debug\mydll\mydll.lib and object \Debug\mydll\mydll.exp
    \Debug\mydll\mydll.dll : fatal error LNK1169: one or more multiply defined symbols found




    With the /FORCE:MULTIPLE I can build the DLL but it gives a bunch of warnings...

    Thanks in advance

    Xico

    Reply With Quote
      #2    
    Old January 27th, 2000, 12:52 PM
    Feng Yuan Feng Yuan is offline
    Elite Member
     
    Join Date: Oct 1999
    Location: WA
    Posts: 2,393
    Feng Yuan is on a distinguished road (10+)
    Re: _DllMain@12 already defined error

    Either remove MFC or remove DllMain from your source code.

    *** Appreciate good/interesting Windows graphics programming questions ***
    Reply With Quote
      #3    
    Old January 31st, 2000, 01:07 AM
    manoj singh manoj singh is offline
    Junior Member
     
    Join Date: Dec 1999
    Posts: 1
    manoj singh is an unknown quantity at this point (<10)
    Re: _DllMain@12 already defined error

    Hello

    I am getting the linker error message "_DllMain12 already defined in .obj module", when I am including &lt;afxdb.h&gt; file in my dll project. I cant delete DllMain from my project, because I am doing object initialisation in DllMain.

    urgently seeking your help
    manoj singh

    Reply With Quote
      #4    
    Old January 31st, 2000, 01:19 AM
    Feng Yuan Feng Yuan is offline
    Elite Member
     
    Join Date: Oct 1999
    Location: WA
    Posts: 2,393
    Feng Yuan is on a distinguished road (10+)
    Re: _DllMain@12 already defined error

    Delete DllMain, you have to.

    Move the inititialization to your CWinApp derived class' object.

    *** Appreciate good/interesting Windows graphics programming questions ***
    Reply With Quote
      #5    
    Old January 31st, 2000, 03:25 AM
    babu1999 babu1999 is offline
    Member
     
    Join Date: Jan 2000
    Location: India
    Posts: 48
    babu1999 is an unknown quantity at this point (<10)
    Re: _DllMain@12 already defined error

    Hi,
    I'm also getting the same problem in case of Regular DLLs Dynamically Linked to MFC.

    I get this error whenver I add


    AFX_MANAGE_STATE(AfxGetStaticModuleState( ));




    statement to my exported functions where MFC is used.

    If I remove that statement from all exported functions NO ERROR is reported.

    Pl. help.

    Reply With Quote
      #6    
    Old January 31st, 2000, 04:05 AM
    Feng Yuan Feng Yuan is offline
    Elite Member
     
    Join Date: Oct 1999
    Location: WA
    Posts: 2,393
    Feng Yuan is on a distinguished road (10+)
    Re: _DllMain@12 already defined error

    Do you have your own DllMain, remove it if you're using MFC. MFC like to take it over to do some initialization.

    *** Appreciate good/interesting Windows graphics programming questions ***
    Reply With Quote
      #7    
    Old January 31st, 2000, 04:17 AM
    babu1999 babu1999 is offline
    Member
     
    Join Date: Jan 2000
    Location: India
    Posts: 48
    babu1999 is an unknown quantity at this point (<10)
    Re: _DllMain@12 already defined error

    If I write my own dllmain then do i have to call


    AFX_MANAGE_STATE(AfxGetStaticModuleState( ));




    function?

    Reply With Quote
      #8    
    Old March 8th, 2000, 06:42 PM
    Dmitriy Dmitriy is offline
    Member +
     
    Join Date: Apr 1999
    Location: Toronto, ON
    Posts: 713
    Dmitriy is an unknown quantity at this point (<10)
    Re: _DllMain@12 already defined error



    DOC: AfxGetStaticModuleState() Causes Errors in an Extension DLL
    Last reviewed: July 28, 1997
    Article ID: Q161589
    The information in this article applies to:
    Microsoft Visual C++, 32-bit Edition, version 4.1


    SUMMARY
    The Visual C++ 4.1 MFC documentation indicates that MFC Extension DLLs need to use the macro expression "AFX_MANAGE_STATE(AfxGetStaticModuleState());" at the top of every exported DLL function. This is incorrect; MFC Extension DLLs do not need to use this expression.

    This error was fixed in the documentation for Visual C++ 4.2.



    MORE INFORMATION
    Under the subheading "Extension DLLs" of the article "Visual C++ Books -&gt; MFC 4.2 -&gt; Programming with MFC:Encyclopedia - &gt; Dynamic-Link Libraries (DLLs) -&gt; Dynamic-Link Libraries (DLLs)," the following text appears:


    "If you have a resource in your DLL, such as a dialog, you need to use
    the macro AFX_MANAGE_STATE to switch the MFC module state correctly, so
    that Windows looks in the DLL and not in the EXE for the resource. This
    can be done by adding the following line of code to the beginning of
    functions exported from the DLL:

    AFX_MANAGE_STATE(AfxGetStaticModuleState( ))"


    This is incorrect. Extension DLLs do not need to add this macro at the top of every exported function . The AFX_MANAGE_STATE macro can be used inside of callbacks or custom window procedures to properly adjust the current module state, but it should be used with AfxGetAppModuleState() or a specific module state instance instead of AfxGetStaticModuleState().
    Any attempt to use AfxGetStaticModuleState( ) in an Extension DLL will result in possible run-time problems and the following linker errors:


    "mfcs40d.lib(dllmodul.obj) : error LNK2005: __pRawDllMain already
    defined in testdll1.obj
    mfcs40d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined
    in testdll1.obj
    mfcs40d.lib(dllmodul.obj) : warning LNK4006: __pRawDllMain already
    defined in testdll1.obj; second definition ignored
    mfcs40d.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined
    in testdll1.obj; second definition ignored"


    The incorrect paragraph was removed from the documentation for Visual C++ in version 4.2.

    Keywords : MfcDLL
    Technology : kbInetDev
    Version : 4.10
    Platform : NT WINDOWS
    Issue type : kbdocerr
    Solution Type : kbdocfix



    --------------------------------------------------------------------------------

    ================================================================================


    THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

    Last reviewed: July 28, 1997
    © 1998 Microsoft Corporation. All rights reserved. Terms of Use.




    Have a nice day!

    Reply With Quote
      #9    
    Old June 28th, 2008, 12:59 AM
    zilongcsdn zilongcsdn is offline
    Junior Member
     
    Join Date: Jun 2006
    Posts: 1
    zilongcsdn is an unknown quantity at this point (<10)
    Re: _DllMain@12 already defined error

    This issue seems you redefined dllmain function, however, you not.
    The way to fix it is just to put mfc42u.lib and mfcs42u.lib front of msvcrt.lib and msvcprt.lib in VC++ project setting.
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:56 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009