《COM技术内幕》第八章的问题
第八章中有个完整的例子,也就是在书的145页。不知有谁看过,还请大家劳驾一下了。书中给了两个组件,也就是两个清单8-3和8-4,不知道这两个程序能放到一起运行不。我试了一下,说是不行。问题出现如下的错误:
--------------------Configuration: Client - Win32 Debug--------------------
Linking...
CMPNT1.OBJ : error LNK2005: "public: virtual long __stdcall CFactory::QueryInterface(struct _GUID const &,void * *)" (?QueryInterface@CFactory@@UAGJABU_GUID@@PAPAX@Z) already defined in CMPNT2.OBJ
CMPNT1.OBJ : error LNK2005: "public: virtual unsigned long __stdcall CFactory::AddRef(void)" (?AddRef@CFactory@@UAGKXZ) already defined in CMPNT2.OBJ
CMPNT1.OBJ : error LNK2005: "public: virtual unsigned long __stdcall CFactory::Release(void)" (?Release@CFactory@@UAGKXZ) already defined in CMPNT2.OBJ
CMPNT1.OBJ : error LNK2005: "public: virtual long __stdcall CFactory::CreateInstance(struct IUnknown *,struct _GUID const &,void * *)" (?CreateInstance@CFactory@@UAGJPAUIUnknown@@ABU_GUID@@PAPAX@Z) already defined in CMPNT2.OBJ
CMPNT1.OBJ : error LNK2005: "public: virtual long __stdcall CFactory::LockServer(int)" (?LockServer@CFactory@@UAGJH@Z) already defined in CMPNT2.OBJ
CMPNT1.OBJ : error LNK2005: _DllCanUnloadNow@0 already defined in CMPNT2.OBJ
CMPNT1.OBJ : error LNK2005: _DllGetClassObject@12 already defined in CMPNT2.OBJ
CMPNT1.OBJ : error LNK2005: _DllRegisterServer@0 already defined in CMPNT2.OBJ
CMPNT1.OBJ : error LNK2005: _DllUnregisterServer@0 already defined in CMPNT2.OBJ
CMPNT1.OBJ : error LNK2005: _DllMain@12 already defined in CMPNT2.OBJ
CMPNT1.OBJ : warning LNK4006: "public: virtual long __stdcall CFactory::QueryInterface(struct _GUID const &,void * *)" (?QueryInterface@CFactory@@UAGJABU_GUID@@PAPAX@Z) already defined in CMPNT2.OBJ; second definition ignored
CMPNT1.OBJ : warning LNK4006: "public: virtual unsigned long __stdcall CFactory::AddRef(void)" (?AddRef@CFactory@@UAGKXZ) already defined in CMPNT2.OBJ; second definition ignored
CMPNT1.OBJ : warning LNK4006: "public: virtual unsigned long __stdcall CFactory::Release(void)" (?Release@CFactory@@UAGKXZ) already defined in CMPNT2.OBJ; second definition ignored
CMPNT1.OBJ : warning LNK4006: "public: virtual long __stdcall CFactory::CreateInstance(struct IUnknown *,struct _GUID const &,void * *)" (?CreateInstance@CFactory@@UAGJPAUIUnknown@@ABU_GUID@@PAPAX@Z) already defined in CMPNT2.OBJ; second definition
ignored
CMPNT1.OBJ : warning LNK4006: "public: virtual long __stdcall CFactory::LockServer(int)" (?LockServer@CFactory@@UAGJH@Z) already defined in CMPNT2.OBJ; second definition ignored
CMPNT1.OBJ : warning LNK4006: _DllCanUnloadNow@0 already defined in CMPNT2.OBJ; second definition ignored
CMPNT1.OBJ : warning LNK4006: _DllGetClassObject@12 already defined in CMPNT2.OBJ; second definition ignored
CMPNT1.OBJ : warning LNK4006: _DllRegisterServer@0 already defined in CMPNT2.OBJ; second definition ignored
CMPNT1.OBJ : warning LNK4006: _DllUnregisterServer@0 already defined in CMPNT2.OBJ; second definition ignored
CMPNT1.OBJ : warning LNK4006: _DllMain@12 already defined in CMPNT2.OBJ; second definition ignored
Creating library Debug/Client.lib and object Debug/Client.exp
Client.exp : warning LNK4070: /OUT:Cmpnt.dll directive in .EXP differs from output filename "Debug/Client.exe"; ignoring directive
Debug/Client.exe : warning LNK4086: entrypoint "_mainCRTStartup" is not __stdcall with 12 bytes of arguments; image may not run
Debug/Client.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
Client.exe - 11 error(s), 12 warning(s)
我是刚开始学,不知道为什么会这样。怎样修改才能改变这样的错误。
另外是即使先用一个程序清单8-3或8-4不会出现错误,但运行出来的程序也是一闪而过,不知为何?请教!