Like Tree1Likes
  • 1 Post By jimblumberg

Help with first program (Hello world)

This is a discussion on Help with first program (Hello world) within the C++ Programming forums, part of the General Programming Boards category; I'm using the book "C++ Primer Plus 6e" by Prata and I feel like I'm following the instructions step-by-step. I ...

  1. #1
    Registered User
    Join Date
    Jul 2012
    Posts
    4

    Help with first program (Hello world)

    I'm using the book "C++ Primer Plus 6e" by Prata and I feel like I'm following the instructions step-by-step.

    I am using Microsoft Visual C++ 2010 Express. I start a new project and select "Win32 Console Application" and on the next screen I ensure that "Console application" is selected and I uncheck "Precompiled Header" and put a check in the box for "Empty Project."

    Once the project is created, I make a new .cpp file and type the following code

    Code:
    #include <iostream>
    int main()
    {
        using namespace std;
        cout << "Come up and C++ me some time.";
        cout << endl;
        cout << "You won't regret it!" << endl;
        return 0;
    }
    When I try to build/debug I am greeted with this error message
    Code:
    1>------ Build started: Project: thisdoesntwork, Configuration: Debug Win32 ------
    1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
    1>c:\Users\Leewiz\Documents\Visual Studio 2010\projects\thisdoesntwork\Debug\thisdoesntwork.exe : fatal error LNK1120: 1 unresolved externals
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    I did a quick google search and tried a few different things to no avail. Hopefully this forum can help!

    Thanks in advance

  2. #2
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,678
    The piece of code you wrote is ok.Something in your installation is not ok

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    2,713
    You need to change your compiler settings. When you created your project you didn't select the proper project type. You selected a Win32 project instead of a console application.

    Jim
    stahta01 likes this.

  4. #4
    Registered User
    Join Date
    Jul 2012
    Posts
    4
    Quote Originally Posted by jimblumberg View Post
    You selected a Win32 project instead of a console application.
    I selected "Win32 console application". There is no other Console application. The only other "console application" option is "CLR Console Application" which throws in a whole bunch of extra stuff that I don't understand. All of the books I've looked at and instructions on the internet have a completely blank slate when they write this "Hello, World" program.

  5. #5
    Registered User
    Join Date
    Jul 2012
    Posts
    4
    What might be wrong with my install? I installed it fresh off the microsoft website and changed nothing.

  6. #6
    Registered User
    Join Date
    Jul 2012
    Posts
    4
    I figured it out from a reply on reddit! I had to add the source.cpp to the solution! I thought it was automatically in there. Hah! Thanks for the replies!

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,659
    Quote Originally Posted by Lee Sager
    I selected "Win32 console application".
    That should be correct.

    Quote Originally Posted by Lee Sager
    What might be wrong with my install?
    I don't know, but it does look like your installation of Microsoft Visual C++ 2010 Express has a problem. You could try creating a new project using the same steps and see if there is any difference. If that still fails, then re-installing might be the way out.

    EDIT:
    Quote Originally Posted by Lee Sager
    I had to add the source.cpp to the solution!
    Oh, right.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,678
    Now CODE

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 11-16-2011, 07:42 AM
  2. Problem with Hello World program
    By JakeyWakey in forum C++ Programming
    Replies: 3
    Last Post: 10-18-2008, 01:25 PM
  3. MSvc++ isn't compiling hello world program
    By avgprogamerjoe in forum C++ Programming
    Replies: 13
    Last Post: 09-23-2007, 12:43 PM
  4. Problems compiling world's easiest program
    By markcls in forum C++ Programming
    Replies: 12
    Last Post: 03-26-2007, 01:56 AM
  5. microsoft world domination program
    By iain in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 12-21-2001, 10:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21