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++ 2010
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Ivor Horton's Beginning Visual C++ 2010
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2010 by Ivor Horton; ISBN: 9780470500880
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2010 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
  #11 (permalink)  
Old October 22nd, 2012, 01:48 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

nice post---------
  #12 (permalink)  
Old October 22nd, 2012, 12:41 PM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 66
Thanks: 0
Thanked 4 Times in 4 Posts
Default

You are welcome. I hope you checked out the links provided for more detailed instructions.

drpepper
  #13 (permalink)  
Old November 27th, 2012, 08:33 PM
Registered User
Points: 6, Level: 1
Points: 6, Level: 1 Points: 6, Level: 1 Points: 6, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can't Get "Ex1_02" to compile

I just began going through book. This is the "Creating an Empty Console Project" example in Chap 1. I followed all of the instructions to create an empty project with Character Set = "Not Set". I used the downloaded code to upload into code window. The code is as follows:

// Ex1_02.cpp A simple console program
#include <iostream> // Basic input and output library

int _main()
{
std::cout << "This is a simple program that outputs some text." << std::endl;
std::cout << "You can output more lines of text" << std::endl;
std::cout << "just by repeating the output statement like this." << std::endl;
return 0; // Return to the operating system
}

and the compiler error message is:

1>------ Build started: Project: Ex1_02, Configuration: Debug Win32 ------
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>c:\users\dad\documents\visual studio 2010\Projects\Ex1_02\Debug\Ex1_02.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I tried deleting and recreating the project a few times but same result. I am using Visual Studio 2010 Express version.

Any ideas, Thanks.
  #14 (permalink)  
Old November 28th, 2012, 02:44 AM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 66
Thanks: 0
Thanked 4 Times in 4 Posts
Default

BRYANH,

I have a suggestion, explanation of error codes, and the source of the error for you.

suggestion
Please don't take this wrong. Experience in learning a few languages has proven to me that the following is true. If you truly want to learn to write code, it will be of great help to you to manually type the code. By manually typing the code you learn the structure and syntax. As time rolls along you will begin to see problems before you attempt to build the program. I have found that writing and debugging my own code, I have become better at spotting problems. Granted, at this early stage of learning you will be merely typing what you see in the book. By actively using your eyes, hands, and mind you are creating the mental building blocks of understanding. After I have a properly running program, I check it against the code provided in the download. This way I see if there is a difference between the two. Oftentimes examination of the two reveals why the downloaded code is better. It is all a stepwise learning process.

explanation of errors
This is one of the ways I find out what error codes mean.
LNK2001 as found in the help files includes the following excerpts
Quote:
unresolved external symbol "symbol"

Code references something (such as a function, variable, or label) that the linker can't find in the libraries and object files.

This error message is followed by fatal error LNK1120. ...
...What the code asks for doesn't exist (the symbol is spelled incorrectly or uses the wrong case, for example).
...and for LNK1120
Quote:
number unresolved externals

Error LNK1120 gives you a count ( number) of unresolved externals for this link. The conditions that cause unresolved externals are described with error LNK2001, which precedes this error message (once for each unresolved external).
Of special note here is that LNK means a linker error. If you ever see an error like Cxxxx, where xxxx represents a four digit number, it is a compiler error.

source of the error
Let's look at the error you received and how it applies to the explanations above.
Code:
1>------ Build started: Project: Ex1_02, Configuration: Debug Win32 ------
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>c:\users\dad\documents\visual studio 2010\Projects\Ex1_02\Debug\Ex1_02.exe : fatal error LNK1120: 1 unresolved externals
Pay special attention to the parts in red. There is one error, and it is _main. Now let's look for that in your code.

It is found here in red in your code:
Code:
// Ex1_02.cpp A simple console program
#include <iostream> // Basic input and output library

int _main()
{
std::cout << "This is a simple program that outputs some text." << std::endl;
std::cout << "You can output more lines of text" << std::endl;
std::cout << "just by repeating the output statement like this." << std::endl;
return 0; // Return to the operating system
}
Now compare this to the code in the book which is
Code:
int main()
Do you see the difference? It is the underscore (_) between int and main. This is called a syntax error. If you delete the underscore and keep the space between int and main, the program should build and run properly.

C++ is very sensitive to spelling, upper case versus lower case letters, and quite a few other syntax errors. Don't let this get you down. Everyone (including me) has experienced this type of problem. Even expert programmers experience syntax errors.

If memory serves me correctly, I have posts and/or topics about basic troubleshooting steps and how to find error codes. Search my posts to see if you can find them. If you can't, reply back and I'll try to link to them in my reply back to you.

regards,
drpepper

Last edited by drpepper; November 28th, 2012 at 02:50 AM..
  #15 (permalink)  
Old November 29th, 2012, 10:17 PM
Registered User
Points: 6, Level: 1
Points: 6, Level: 1 Points: 6, Level: 1 Points: 6, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can't Get "Ex1_02" to compile

Hi drpepper,

Thanks very much for the extensive reply. I actually thought I tried various iterations of the spelling but I guess not. It worked perfectly with "main" in place of "_main".

I have actually done lots of "programming" but virtually all of it (aside from playing with Borland's Turbo Pascal about 25 years ago) has been done in MS VBA language behind Excel. I have always wanted to play around in a real programming environment.

Thanks again for the reply
  #16 (permalink)  
Old November 30th, 2012, 02:37 AM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 66
Thanks: 0
Thanked 4 Times in 4 Posts
Default

BRYANH,

You are quite welcome. I find that I strengthen my understanding by helping others.

Since you are new to Visual C++ and what you call "a real programming environment", I have some suggestions which may make life easier on you as you learn both how to use the IDE and the C++ programming language. If you want the reasons behind my suggestions , feel free to ask.
  1. Use expert settings by navigating: tools > settings > expert settings.
  2. Don't use hot keys or rebuild solution when attempting to compile the first time or compile after debugging.
  3. Check my threads titled basic debugging of programs and what do compiler errors mean? for insight on how to help yourself when debugging. I composed these threads based upon techniques I found to be very helpful to me, especially the compiler errors. It took quite a bit of peeking here and there to find these. I have spent a lot of time in Google in unsuccessful attempts to find the information contained in these threads.
  4. If you have the time to do some reading, there are some other nuggets buried in some of my other posts. I don't remember what all of them are, but sometimes the course of dialog promotes the inclusion of tips or tricks.
I hope you find this helpful. By the way ... I work and attend school; so my progress through the book is limited to the time in between semesters. You may pass me up as you study, but I will always be happy to try to help if I see a notification of a new post in this forum.

regards,
drpepper
 


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
(Chap. 7) Creating Thumbnails/Photo Galleries SmoothAl BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 3 March 2nd, 2010 06:27 AM
Adding existing Console/project ? chiefarchon BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 0 September 19th, 2008 07:51 AM
problem using "string"(CLR project) rsm1235 C++ Programming 0 February 4th, 2006 11:07 AM
Please!!Chap 07-Creating an Installer amouzeshgah VB.NET 2002/2003 Basics 0 September 13th, 2005 11:28 PM
Chap 12 Project tracker - listboxes don't clear trancelife BOOK: Beginning Access 2003 VBA 1 February 14th, 2005 12:15 PM



All times are GMT -4. The time now is 09:29 PM.


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