By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,696 Members | 2,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,696 IT Pros & Developers. It's quick & easy.

Link error LNK2001 in VC7

P: n/a
I have some code that compiles and links fine in VC6 but does not
link in VC7. Here are the relevant parts of the code:

class AView : public CScrollView
{
....
public:
AFX_DISPMAP_ENTRY* _dispatchEntries;
UINT _dispatchEntryCount;
DWORD _dwStockPropMask;
AFX_DATA AFX_DISPMAP dispatchMap;
#ifdef _AFXDLL
static const AFX_DISPMAP* PASCAL _GetBaseDispatchMap();
#endif
virtual const AFX_DISPMAP* GetDispatchMap() const;

}
void AView::MakeMap()
{
#ifdef _AFXDLL
dispatchMap.pfnGetBaseMap = _GetBaseDispatchMap;
#else
dispatchMap.pBaseMap = &CScrollView::dispatchMap;
#endif
_dispatchEntries = new AFX_DISPMAP_ENTRY[nSize];
dispatchMap.lpEntries = _dispatchEntries;
dispatchMap.lpEntryCount = &_dispatchEntryCount;
dispatchMap.lpStockPropMask = &_dwStockPropMask;
_dispatchEntryCount = (UINT) -1;
_dwStockPropMask = (DWORD)-1;
}

#ifdef _AFXDLL
const AFX_DISPMAP* PASCAL AView::_GetBaseDispatchMap()
{ return &CScrollView::dispatchMap; }
const AFX_DISPMAP* AView::GetDispatchMap() const
{ return &dispatchMap; }
#else
const AFX_DISPMAP* AView::GetDispatchMap() const
{ return &dispatchMap; }
#endif

During linking, I get the following error:
error LNK2001: unresolved external symbol "protected: static struct
AFX_DISPMAP const CCmdTarget::dispatchMap"
(?dispatchMap@CCmdTarget@@1UAFX_DISPMAP@@B)

My /LIBPATH includes Vc7/atlmfc/lib which is where I'm
assuming the necessary library resides.

There was a virtually identical problem submitted to
microsoft.public.languages.vc
on July 30, 2002 by sunil, but there was no response.

I would appreciate suggestions how to resolve this.
Tom

Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Tom,

This is because MFC7.0 and 7.1 no longer export CCmdTarget::dispatchMap
from the MFC DLL's, if you look in the corresponding DEF file the export is
no longer present. You can also find this out by doing a dumpbin /Exports
on the lib file that you are linking to.

Since this is a member you can only access it if you are inheriting from
the class anyway and the best thing to do is use the Accessor functions
that are provided to
us. you simply need to change the function to call
CCmdTarget::GetThisDispatchMap()
Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

Nov 17 '05 #2

P: n/a
Hi Gary,

That worked. Thank you very much.

Tom

"Gary Chang[MSFT]" wrote:
Hi Tom,

This is because MFC7.0 and 7.1 no longer export CCmdTarget::dispatchMap
from the MFC DLL's, if you look in the corresponding DEF file the export is
no longer present. You can also find this out by doing a dumpbin /Exports
on the lib file that you are linking to.

Since this is a member you can only access it if you are inheriting from
the class anyway and the best thing to do is use the Accessor functions
that are provided to
us. you simply need to change the function to call
CCmdTarget::GetThisDispatchMap()
Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

Nov 17 '05 #3

P: n/a
OK, Tom,

I am very glad to know it resolved your problem, good luck!
Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.