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
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
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 19th, 2007, 10:38 AM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 18 code compile problem

Has anybody else run into the LNK2019 issue related to CString and using DLLs? I've tried to fix it the way that MS says to do so(http://support.microsoft.com/kb/309801/en-us), but I just can't get it to work. Anybody solve this problem? Seems that it's an issue using the new CString template class vs the old CString class.

I'm getting back this error:
SketcherView.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall CText::CText(class CPoint,class CPoint,class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > >,unsigned long)" (__imp_??0CText@@QAE@VCPoint@@0V?$CStringT@DV?$Str TraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@K@Z) referenced in function "public: void __thiscall CSketcherView::OnLButtonDown(unsigned int,class CPoint)" (?OnLButtonDown@CSketcherView@@QAEXIVCPoint@@@Z)

It refers to the CText call on lines 199-200 in the SketcherView.cpp file. I don't know if the knowledge base article applies or not. The CText function call exists in the Elements.cpp file for the ExtDLLExample DLL.

Please, any ideas as to what I've done wrong?

Stay sane inside insanity
__________________
Stay sane inside insanity
Reply With Quote
  #2 (permalink)  
Old January 23rd, 2007, 01:53 PM
Authorized User
 
Join Date: May 2006
Location: Iver, Bucks., United Kingdom.
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Warlock7,

I went through Chapter 18 about 6 months ago, so unable to recall all that I did. I have, though, found my project files and re-compiled them and Sketcher still works fine. (I did wonder about one aspect; Visual Studio 2005 had a -what seemed -fairly major set of changes recently, so I thought perhaps that was the cause, but evidently not so.)

I suggest using a compare utility to compare your code listing for each file against those in the downloadable exercises and answers. If you look at my posting: P2P Forum > Books > Ivor Horton's Beginning Visual C++ 2005 > Comparing Files... , I found one that suited me and may help you. I did find that some minute typos on my part caused me major problems...

Hope this helps.

Nick

Reply With Quote
  #3 (permalink)  
Old January 23rd, 2007, 02:17 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the suggestions Nick.

I ended up redoing both the Sketcher and the ExtDLLExample projects from scratch using the source code provided by the website with the exact same results. I am at a total loss as to what is wrong with the projects. I've even contacted Ivor Horton with no luck. He says the same thing. I must've missed a step in the set-up or something.

Stay sane inside insanity
Reply With Quote
  #4 (permalink)  
Old January 24th, 2007, 01:28 AM
Authorized User
 
Join Date: May 2006
Location: Iver, Bucks., United Kingdom.
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I would still try something like "Files Comparer".

Another possibility is that something in your Visual Studio installation has been corrupted. If you have someone local to you who runs VS, perhaps try taking your complete project file and compiling it on their installation.

Reply With Quote
  #5 (permalink)  
Old February 20th, 2007, 12:31 PM
Authorized User
 
Join Date: Feb 2007
Location: , , United Kingdom.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi warlock7,

I had exactly the same problem as you with the CText class. I couldn't work out why and when I saw your post I gave up on it and moved the CText class back to the program leaving everything else in the dll.

Anyway, I ran into another problem which I recently posted. In solving that one I seem to have solved the problem I was having with CText. I don't know if the solution will work for you as well but it's worth a try.

The problem seems to be related to the versions of the MFC libraries that the program and the dll link to. It seems that when you create a dll project using the application wizard it chooses by default to use the unicode character set. If you did the same thing as me, when you created your Sketcher application using the wizard you unchecked the unicode libraries box following Mr Horton's advice for the text editor (page 658). I guess because I didn't really understand it, I thought it safer to do the same thing for the Sketcher application.

Anyway, you may find if you bring up the project properties page for the Sketcher application, select the 'Use unicode character set' in the 'Character Set' option and rebuild your project that the problem disappears. It did with me.

If you look in the 'stdafx.h' header file for Sketcher and go to the bottom, you'll see that if _UNICODE is defined it seems to link with a different version of the control set (MFC libraries?). Perhaps this explains the problem. You'll probably also find your Sketcher program starts to look a bit more Windows XP than Windows 98. The dialogue boxes certainly look better and so do the toolbars and window frames.

The main thing, it seems, is to make sure that the program and dll link to the same set of MFC. You can use the unicode or multi-byte character set as long as the same option is selected for both the program and the dll.

Anyway, hopefully it will sort the problem out for you. Let me know if it does.

Dan

Reply With Quote
  #6 (permalink)  
Old February 20th, 2007, 12:39 PM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dan,

That's it!!! I'm glad that you figured this out and I truly appreciate the information. I'd gone to the extent of contacting Ivor Horton directly and he couldn't figure out what was wrong either.

Again, thanks so much for the information. I needed this example in order to make a DLL for a project that I am working on. You are a lifesaver.

Stay sane inside insanity
Reply With Quote
  #7 (permalink)  
Old February 20th, 2007, 01:09 PM
Authorized User
 
Join Date: Feb 2007
Location: , , United Kingdom.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No worries - I'm really glad it helped you out. It's been driving me up the wall as well.

Dan

Reply With Quote
  #8 (permalink)  
Old June 12th, 2007, 06:08 PM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had the exact problem while going through Chapter 18, and your solution just saved me a lot of time. This is probably something that should be printed in the errata.

Kudos for posting the solution and thanks for the help!

Reply With Quote
  #9 (permalink)  
Old January 3rd, 2008, 09:04 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

Dan6,

You also solved it for me. I had exactly the same problem and it was driving me nuts as well. I've even posted to this forum about it but didn't see your post until I searched for the error message.

Thanks a lot. I don't know how you figured that one out.

From one Dan to another.

Dan Crossley
Reply With Quote
Reply


Thread Tools
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
Chapter 18 code won't compile warlock7 Visual C++ 2005 0 January 18th, 2007 03:10 PM
Chapter 18 re: VSS kevinstruckhoff BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 0 August 8th, 2006 11:04 AM
Source Code for Chapter 18 KeithM BOOK: Access 2003 VBA Programmer's Reference 3 August 13th, 2004 11:53 AM



All times are GMT -4. The time now is 09:14 AM.


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