开发者

LNK2005 - ATL base class symbols already defined - What is the root cause?

I a noob to Visual C++, but have used C++ before. I've have spent days on this problem so any help really appreciated.

I've inherited a significant VC6 code base that I'm trying to compile and link with a newer compiler. The underlying dll projects are compiling and linking and the exe project is compiling but not linking. I get errors that look like this ...

MyBaseLib.lib(MyBaseLib.dll) : error LNK2005: "public: __thiscall ATL::CWindowImplRoot<class ATL::CWindow>::CWindowImplRoot<class ATL::CWindow>(void)" (??0?$CWindowImplRoot@VCWindow@ATL@@@ATL@@QAE@XZ) already defined in ClassInMyExe.obj

I've noticed that there are classes in both the exe and the offending MyBaseLib.dll that use ATL, specifically inheriting from CDialogImpl<..>. I've referenced similar questions but I don't see an answer - I don't think that it's as simple as a class definition mistakenly inserted into a header file开发者_如何学Python.

I get the same error in both a VS2010 and VS2005 environments.


Make sure all libraries you use compiled with the same compiler, and with the same c|cpp runtime libraries (/MT or /MD). If there are some old libraries left, this may happen.


I've inherited a significant VC6 code base ...

This can be the cause of the errors.

There are many breaking changes in VC++ 2003/2005/2008. VC 6.0 ATL source codes usually aren't compatible with VC++ 2003 or above.

Take a look at below MSDN pages:

Breaking Changes in ATL 7.0 and MFC 7.0 Since Visual C++ 6.0

Changes in the Visual C++ 2005 Libraries

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜