| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
_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 |
|
#2
|
|||
|
|||
|
Re: _DllMain@12 already defined error
Either remove MFC or remove DllMain from your source code.
*** Appreciate good/interesting Windows graphics programming questions *** |
|
#3
|
|||
|
|||
|
Re: _DllMain@12 already defined error
Hello
I am getting the linker error message "_DllMain12 already defined in .obj module", when I am including <afxdb.h> 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 |
|
#4
|
|||
|
|||
|
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 *** |
|
#5
|
|||
|
|||
|
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. |
|
#6
|
|||
|
|||
|
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 *** |
|
#7
|
|||
|
|||
|
Re: _DllMain@12 already defined error
If I write my own dllmain then do i have to call
AFX_MANAGE_STATE(AfxGetStaticModuleState( )); function? |
|
#8
|
|||
|
|||
|
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 -> MFC 4.2 -> Programming with MFC:Encyclopedia - > Dynamic-Link Libraries (DLLs) -> 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! |
|
#9
|
|||
|
|||
|
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. |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|