Re: Linker error - fooView.obj LNK2005: _IID_IProvideTaskPage already defined in fooDoc.obj

From: Al (anonymous_at_discussions.microsoft.com)
Date: 02/26/04


Date: Thu, 26 Feb 2004 01:46:10 -0800


> Sounds like you have included a header file what declares an IID_ and CLSID_ variable in
> the .h file, and the .h file is now included in two other files. Never declare variables
> in header files.
> joe

Yes, that would produce that error. I don't think I do that though, I'll just double-check... Nope, the text "_IID_ITaskScheduler" (one of the definitions the linker complains about) doesn't appear anywhere in my project. "IID_ITaskScheduler" does appear in .cpp files in calls to CoCreateInstance() but its not in any header files and its not a declaration.

IID_ITaskScheduler is declared as extern in MSTask.h but that shouldn't be a problem and its a Microsoft header file anyway. I don't think having it defined in 2 places is the direct cause.

MSDN says that error LNK2005 is most commonly caused by accidentally linking to both the single and multi threaded libraries... The only likely setting I can find for this is in the [Code Generation] category of the [C/C++] tab of the [Project Settings] dialog where I have selected to use the [Debug Multithreaded DLL] runtime libraries. I can't see how I could be accidentally linking to both libraries. Is there another setting I should be looking at?

Any further ideas?

--- Al.


Loading