C++ MSXML,LINK 错误 "already defined in obj"

C++ MSXML, LINK error "already defined in obj"

我不明白我做错了什么

Common.h

#pragma once
#include "Flisr.h"
#import <msxml3.dll> named_guids
MSXML2::IXMLDOMDocumentPtr   m_plDomDocument;
MSXML2::IXMLDOMElementPtr    m_pDocRoot;

Common.cpp

#include "Common.h"

//some functions

Flisr.cpp

#include "Flisr.h"
#include "Common.h"

//some functions from Common

错误是:

error LNK2005: "class _com_ptr_t<class _com_IIID<struct MSXML2::IXMLDOMDocument,&struct __s_GUID const _GUID_2933bf81_7b36_11d2_b20e_00c04f983e60> > m_plDomDocument" (?m_plDomDocument@@3V?$_com_ptr_t@V?$_com_IIID@UIXMLDOMDocument@MSXML2@@?_GUID_2933bf81_7b36_11d2_b20e_00c04f983e60@@3U__s_GUID@@B@@@@A) already defined in Common.obj

error LNK2005: "class _com_ptr_t<class _com_IIID<struct MSXML2::IXMLDOMElement,&struct __s_GUID const _GUID_2933bf86_7b36_11d2_b20e_00c04f983e60> > m_pDocRoot" (?m_pDocRoot@@3V?$_com_ptr_t@V?$_com_IIID@UIXMLDOMElement@MSXML2@@?_GUID_2933bf86_7b36_11d2_b20e_00c04f983e60@@3U__s_GUID@@B@@@@A) already defined in Common.obj

每次 "#include "Common.h",您都在定义一组新的对象(全局变量),称为 m_plDomDocumentm_pDocRoot。程序范围内只允许其中一个,因此错误是它们已经被定义了。