Visual Studio .NET - error LNK2005: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj)

Asked By sowbhagya on 04-Nov-11 01:52 AM
Hello,

I have created one MFC DLL ( Acrobat plug-in) with CLR support. Without CLR support it works fine. I am getting Error 5 error LNK2005: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj) 
What could be the problem. I have added Afx.h in Stdafx.h.

Please help me to solve this issue.

Thanks,
Sowbhagya
Riley K replied to sowbhagya on 04-Nov-11 02:26 AM


You may receive this error When the C Run-Time (CRT) library and Microsoft Foundation Class (MFC) libraries are linked in the wrong order

Refer this link

http://support.microsoft.com/default.aspx?scid=kb;en-us;q148652

Regards
sowbhagya replied to Riley K on 04-Nov-11 03:08 AM
Thanks for the response.

As per the link, I have added MSVCRTD.lib;mfcs100ud.lib; in project settings/linker/input/Ignore specific library.
I am using Windows 7 with VS 2010. But still it shows same error.
If i remove

AFX_MANAGE_STATE(AfxGetStaticModuleState());


it works fine. but it fails in

VERIFY(AfxSetModuleState(AfxGetThreadState()->m_pPrevModuleState) ==

&afxModuleState);

dllmodul.cpp

What could be the problem.
Please help me to solve this issue.

Thanks,
Sowbhagya
Riley K replied to sowbhagya on 04-Nov-11 05:35 AM


Refer this link

http://