Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > BOOK: Ivor Horton's Beginning Visual C++ 2005
| Search | Today's Posts | Mark Forums Read
BOOK: Ivor Horton's Beginning Visual C++ 2005
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2005 by Ivor Horton; ISBN: 9780764571978
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 2nd, 2007, 04:17 PM
Authorized User
 
Join Date: Oct 2005
Location: Gateshead, Tyne and Wear, United Kingdom.
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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 {}
__________________
Dan Crossley
 
Old December 18th, 2007, 06:06 AM
Registered User
 
Join Date: Dec 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


 
Old December 18th, 2007, 08:00 AM
Authorized User
 
Join Date: Oct 2005
Location: Gateshead, Tyne and Wear, United Kingdom.
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old December 19th, 2007, 07:12 AM
Registered User
 
Join Date: Dec 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old January 10th, 2008, 12:11 PM
Registered User
 
Join Date: Jan 2008
Location: amherst, New York, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old January 10th, 2008, 04:40 PM
Registered User
 
Join Date: Jan 2008
Location: amherst, New York, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 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
 
Old January 11th, 2008, 03:52 AM
Authorized User
 
Join Date: Oct 2005
Location: Gateshead, Tyne and Wear, United Kingdom.
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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




Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem : Sketcher in chapter 14 chang82 BOOK: Ivor Horton's Beginning Visual C++ 2005 1 September 8th, 2008 02:29 AM
Chapter 14 Code Error? pherank BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 July 4th, 2008 09:05 PM
Linker Error, Chapter 18 Spasticus BOOK: Ivor Horton's Beginning Visual C++ 2005 4 February 20th, 2008 05:04 AM
Wrox United - chapter 14 - error SqlDependency tom_10000001 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 November 10th, 2006 06:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.