Search code examples
c++visual-c++visual-studio-2013mfccil

Why is my C++ ATL project linking in a CIL library?


I am getting this linker error from VC++2013:

1>* CIL library *(* CIL module *) : 
error LNK2005: _DllMain@12 already defined in mfcs120u.lib(dllmodul.obj)

This is a pure C++ project, a COM DLL containing an "ATL simple object", and "No Common Language Runtime Support" is selected in the General project settings. I literally just wizard-created it and it has the same settings as other, working, COM DLLs.

I need to link with the MFC library, not a .NET related library. How could this CIL library possibly end up in the build?


Solution

  • OK, if anyone needs this for future reference:

    This happens when MFC headers are added to an ATL project for which Use MFC was not selected during project creation in the ATL wizard.

    Reason: The generated dllmain.cpp is a bit different for MFC-enabled COM DLLs, but is easily adaptible later when looking at the wizard outputs.