Re: Linker error - fooView.obj LNK2005: _IID_IProvideTaskPage already defined in fooDoc.obj
From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 02/26/04
- Next message: Joseph M. Newcomer: "Re: kind of character based macro functionality"
- Previous message: Joseph M. Newcomer: "Re: How to access a static member variable within __asm { }"
- In reply to: Al: "Re: Linker error - fooView.obj LNK2005: _IID_IProvideTaskPage already defined in fooDoc.obj"
- Next in thread: Al: "RE: Linker error - fooView.obj LNK2005: _IID_IProvideTaskPage already defined in fooDoc.obj"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 26 Feb 2004 05:27:51 -0500
It is clear that you are declaring the variable in both the view and the document.
However, it is impossible to guess as to how you got this symbol defined twice.
I suspect that the problem lies with the INITGUID definition. Go search for DEFINE_GUID in
basetyps.h and read the comments surrounding it..
My analysis consisted of:
search all header files for the definition if IID_ITaskScheduler
discover it is a DEFINE_GUID macro
search for the definition of DEFINE_GUID
read the comments
It is obvious from the macro definition and the comments that if you got the INITGUID
definition wrong, you will get multiple definitions.
A more elaborate diagnosis would have consisted of adding the /P (note the uppercase)
option manually to the command line and recompiling both the view and doc files (don't
compile anything else if you can help it; it will take forever and massive amounts of disk
space), then search the resulting .i files for declarations of the offending variable, and
see where it came from. This would have revealed the expansion of the macro gave two
declarations, one in the document and one in the view.
The MSDN article that indicates LNK2005 errors are from conflicts with single-threaded and
multithreaded libraries would refer to symbols in the single-threaded and multithreaded
libraries, and these symbols do not releate to the single-threaded or multithreaded
libraries, so the article is completely irrelevant. Unless someone in the header files is
trying real, real hard, iIt would not cause symbols that have nothing to do with the
libraries to become multiply-defined.
Look for simple solutions first. And the simple solution is that you declared it twice.
joe
On Thu, 26 Feb 2004 01:46:10 -0800, "Al" <anonymous@discussions.microsoft.com> wrote:
>> 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.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
- Next message: Joseph M. Newcomer: "Re: kind of character based macro functionality"
- Previous message: Joseph M. Newcomer: "Re: How to access a static member variable within __asm { }"
- In reply to: Al: "Re: Linker error - fooView.obj LNK2005: _IID_IProvideTaskPage already defined in fooDoc.obj"
- Next in thread: Al: "RE: Linker error - fooView.obj LNK2005: _IID_IProvideTaskPage already defined in fooDoc.obj"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|