none
Hello World - "The Project is out of Date" RRS feed

  • Question

  • Hello, 

    I've been trying to learn C++ through a book which uses the 2008 version of Visual Studio. I created a project and the file, as the book instructed me, and typed in the following: 

    #include <iostream>


    int main(void)

    {
    using std::cout;
    cout << "Hello World!\n";
    return 0;

    }

    Again, just as the book said. Then it instructed me to use "Start without Debugging program, and it said if I typed in everything correct, another window should pop up displaying "Hello World!". Instead, it's saying that "This project is out of date, would you like to build it. So I said yes, and it something, and gave me three errors. One of them was that I didn't write ' include "stdafx.h" ' . I later learned that it has to go before the <iostream>, and so I added the line before it as follows: 

    #include "stdafx.h"
    #include <iostream>


    int main(void)

    {
    using std::cout;
    cout << "Hello World!\n";
    return 0;

    }

    Now when I do the same thing, it's giving me the other two errors: 

    LNK2005_main already defined in Hello World.obj

    LNK1169 one or more multiply defined symbols found

    Please tell me how can I fix this? I'm new to programming, and have zero idea on how to get rid of this error. The book said it's going to explain everything later. For now I just need to be able to run this Hello World program. 

    Thank you!

    Thursday, March 22, 2018 3:59 AM

All replies

  • Now when I do the same thing, it's giving me the other two errors: 

    LNK2005_main already defined in Hello World.obj

    LNK1169 one or more multiply defined symbols found


    Make sure you only have that source code in the .cpp file once, and that
    you don't have more than one .cpp file in the project that has that
    code in it.

    Then try this:

    Open the Build menu and click on Clean Solution.

    When it completes, open the Build menu and click on Rebuild Solution.

    Any errors?

    - Wayne

    • Proposed as answer by Guido Franzke Thursday, March 22, 2018 11:26 AM
    Thursday, March 22, 2018 4:47 AM
  • Hi Arijit_Das,

    Thank you for posting here.

    According to the error message, you can use the /FORCE or /FORCE:MULTIPLE option overrides this error.

    For more information, please refer to this document.

    If your issue has been resolved, please remember to close your thread by marking useful posts as answer that can be helpful for other person with same issue.

    Best Regards,

    Hart


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 23, 2018 7:41 AM
    Moderator