竟然有这样的连接错误!:-< 500分!
在下用MFC制作COM时,竟出现了奇怪的连接错误:
部分原文件:
//1.GUIDs.h
#ifndef GUID_H
#define GUID_H
// ComMyComTest Class GUID
// {E6C202F1-E5E7-11d3-8433-00C02600C221}
DEFINE_GUID(CLSID_MyComTest,
0xe6c202f1, 0xe5e7, 0x11d3, 0x84, 0x33, 0x0, 0xc0, 0x26, 0x0, 0xc2, 0x21);
// IMyComTest Interface GUID
// {E6C202F2-E5E7-11d3-8433-00C02600C221}
DEFINE_GUID(IID_IMyComTest,
0xe6c202f2, 0xe5e7, 0x11d3, 0x84, 0x33, 0x0, 0xc0, 0x26, 0x0, 0xc2, 0x21);
#endif
//2.IMyComTest
#include "GUIDs.h"
// New interface declaration
DECLARE_INTERFACE_(IMyComTest, IUnknown)
{
// IFortuneTeller
STDMETHOD(ShowDBResult)() PURE;
};
typedef IMyComTest* PIMyComTest;
//3.ComMyComTest.h
......
#include "IMyComTest.h"
......
//4.ComMyComTest.cpp
// ComMyComTest.cpp : implementation file
//
#include "stdafx.h"
#include "ComTest.h"
#include "ComMyComTest.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// ComMyComTest
// Support dynamic creation
IMPLEMENT_DYNCREATE(ComMyComTest, CCmdTarget)
// Support a class factory
IMPLEMENT_OLECREATE(ComMyComTest,"MyComTest",
0xe6c202f1, 0xe5e7, 0x11d3, 0x84, 0x33, 0x0, 0xc0, 0x26, 0x0, 0xc2, 0x21);
// Map the various interfaces onto the nested interface classes
BEGIN_INTERFACE_MAP(ComMyComTest,CCmdTarget)
INTERFACE_PART(ComMyComTest,IID_IMyComTest,CInnerMyComTest)
// ^^^^^^^^^^^^^^
// ^^^^^^^^^^^^^^
END_INTERFACE_MAP()
......
编译已通过,可连接时出现以下错误:
--------------------Configuration: ComTest - Win32 Debug--------------------
Linking...
Creating library Debug/ComTest.lib and object Debug/ComTest.exp
ComMyComTest.obj : error LNK2001: unresolved external symbol _IID_IMyComTest
Debug/ComTest.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
ComTest.dll - 2 error(s), 0 warning(s)
问题是下画^^^^^^^^^^线的IID_IMyComTest不认识。
不知哪位大侠肯赐教!500分哟!!!