1
votes

I upgraded my Win32 project from VC6 to VC2010, and fixed a lot of codes which only work on VC6, compiling is OK, but when the project began linking, it failed with the following message

LINK : fatal error LNK1104: cannot open file 'mfc42ud.lib'

I tried to find where the MFC42ud is referred, but I cannot, it drives me mad.

Could anyone help me?

updated:

Now I downloaded the MFC42ud.lib, but there is still link error, now it becomes

atlsd.lib(atltypes.obj) : error LNK2005: "public: __thiscall CRect::CRect(void)" (??0CRect@@QAE@XZ) already defined in mfc42ud.lib(MFC42uD.DLL)

atlsd.lib(atltypes.obj) : error LNK2005: "public: int __thiscall CRect::Width(void)const " (?Width@CRect@@QBEHXZ) already defined in mfc42ud.lib(MFC42uD.DLL)

atlsd.lib(atltypes.obj) : error LNK2005: "public: int __thiscall CRect::Height(void)const " (?Height@CRect@@QBEHXZ) already defined in mfc42ud.lib(MFC42uD.DLL)

LINK : fatal error LNK1104: cannot open file 'mfcs42ud.lib'

It seems it is not compatible if I just copy the MFC42ud.lib, so now error is multiple definition

3

3 Answers

2
votes

OK, at last I resolved it. It is because there are some libs I need link, and there is some linkage information in these libs.

The reason is the Microsoft VC specified preprocessor #pragma comment(lib, "some.lib")

Actually it is really a bad solution, especially to link system provided libs, like mfc libs. Even you upgraded the project, it still wants to link the old mfc libs.

The solution is to ignore the old mfc libs.

1
votes

It is Unicode Debug version of the MFC DLL for Visual Studio 6, part of optional parts during Visual Studio 6 installation.

Install it from the VS6 installation CD.

Reference: http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/46a26f16-a407-4628-962b-2a6899391293/

p.s. it's Google's first result, by the way.

0
votes

In my case, my project was linking against another library, and that library had been built with

#pragma comment(lib, "mfc42.lib") 

inside it.

Linking that library into my project instructed my project to link against mfc42.lib, even though I never had any such setting.

Tracking down and removing the offending library was not easy.