Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > BOOK: Ivor Horton's Beginning Visual C++ 2005
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
  #2 (permalink)  
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


  #3 (permalink)  
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
  #4 (permalink)  
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

  #5 (permalink)  
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
  #6 (permalink)  
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
  #7 (permalink)  
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
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:15 PM.


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