p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Ivor Horton's Beginning Visual C++ 2005 (http://p2p.wrox.com/forumdisplay.php?f=249)
-   -   Linker Error when buidling Sketcher - Chapter 14 (http://p2p.wrox.com/showthread.php?t=64240)

Spasticus December 2nd, 2007 04:17 PM

Linker Error when buidling Sketcher - Chapter 14
 
I followed the instructions to page 754 (Running Sketcher).
Then when I tried to build it, I got these linker errors:

Compiling...
Elements.cpp
Linking...
Elements.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CElement::Draw(class CDC *)" (?Draw@CElement@@UAEXPAVCDC@@@Z)
C:\Documents and Settings\Danny Crossley\My Documents\Visual Studio 2005\Projects\Ivor\Practice\Sketcher\Debug\Sketche r.exe : fatal error LNK1120: 1 unresolved externals

This is not very helpful. Clicking on the error messages does nothing and pressing F1 just repeats the error message in similarly vague terms. Can anybody tell me how to find out where these "unresolved externals" are in my code? I compared it with the code I typed in with the code from the book and cannot see any difference.

Dan Crossley

P.S. I've found the error:

class CElement : public CObject
{
protected:
    COLORREF m_Color; // Colour of an element
    CRect m_EnclosingRect; // Rectangle enclosing an element
    int m_Pen; // Pen width
public:
    virtual ~CElement();
    virtual void Draw(CDC* pDC) {} // I HAD A SEMICOLON INSTEAD OF {}

tonyjeffs December 18th, 2007 06:06 AM

Linking...
Elements.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CElement::Draw(class CDC *)" (?Draw@CElement@@UAEXPAVCDC@@@Z)


Dan,
You did well to find the error.
I got something similar earlier on in Sketcher. I gave up and started again. It worked fine the second time around, but I've started to make back-ups of the project regularly so that if it all goes wrong, I don't have to start from scratch.

Looking at your error message which I don't really understand, your remedy sheds light on it. The part CElement::Draw(class CDC *) must mean: look at the class CElement, and the function Draw()
.............

Here's the error I got:
1>Sketcher.obj : error LNK2001: unresolved external symbol "protected: virtual struct AFX_MSGMAP const * __thiscall CAboutDlg::GetMessageMap(void)const " (?GetMessageMap@CAboutDlg@@MBEPBUAFX_MSGMAP@@XZ)

So I guess that means I have to look at the CAboutDlg class, and the function GetMessageMap(), 'cept that there isn't such a function :(
Hmm...

Tony



Spasticus December 18th, 2007 08:00 AM

Tony,

If you do Class View, it's there. It's defined inside the DECLARE_MESSAGEMAP() macro, which is in afxwin.h (line 1109 on mine).

Dan Crossley

tonyjeffs December 19th, 2007 07:12 AM

Dan,
Aha!
That makes a lot of sense. - thanks for pointing me in the right direction.
I'll have a look at it.


I'm on CH 13, but I'm going to take a few days off because I think I'm trying to go too fast.

Cheers
Tony


rahulpatibandla January 10th, 2008 12:11 PM

Hey Tony,

I'm getting the LNK2001 and LNK2019 errors something like this.

Sage.obj : error LNK2001: unresolved external symbol "protected: virtual struct AFX_MSGMAP const * __thiscall Sage::GetMessageMap(void)const " (?GetMessageMap@Sage@@MBEPBUAFX_MSGMAP@@XZ)
Sage.obj : error LNK2019: unresolved external symbol "public: int __thiscall Sage::WritetoSP(char *,void *,double)" (?WritetoSP@Sage@@QAEHPADPAXN@Z) referenced in function "public: void __thiscall Sage::SageDTMFFreq(class Sage *,char *,void *,double,double)" (?SageDTMFFreq@Sage@@QAEXPAV1@PADPAXNN@Z)
.\Debug/TE1.exe : fatal error LNK1120: 2 unresolved externals

In the forum I have seen your post regarding the LNK2001 error, but I didn't find the exact solution for it.

Please can you help out..I'm stuck with it since yesterday.

Any help from you is highly appreciated.

Looking forward to hear from you.

Regards,
Rahul

rahul patibandla

rahulpatibandla January 10th, 2008 04:40 PM

 Hey Dan,

I'm getting the LNK2001 error something like this.

Sage.obj : error LNK2001: unresolved external symbol "protected: virtual struct AFX_MSGMAP const * __thiscall Sage::GetMessageMap(void)const " (?GetMessageMap@Sage@@MBEPBUAFX_MSGMAP@@XZ)
.\Debug/TE1.exe : fatal error LNK1120: 2 unresolved externals

In the forum I have seen your post regarding the LNK2001 error, but I didn't find the exact solution for it.

Please can you help out..I'm stuck with it since yesterday.

Any help from you is highly appreciated.

Looking forward to hear from you.

Regards,
Rahul

rahul patibandla

rahul patibandla

Spasticus January 11th, 2008 03:52 AM

Rahul,

Based on what I've learned from my LNK2001 linker errors, I would interpret your error as being somewhere within the getMessageMap() function and the AFX_MSGMAP structure and would look in there, comparing yours with the code from the book. Have you missed something out of them?


Dan Crossley


All times are GMT -4. The time now is 07:25 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.