locked
why can't I complie? RRS feed

  • Question

  • Just downloaded visual c++ 2008 - first time that I've used it. Admittably, I'm no expert but can do basic programming using C/C++. I'm trying to compile a simple C program just to get me started, something like;

    #include <iostream.h
    int main()
    {
      cout << "hello" <<endl;
      return 0;
    }
     
    The program won't build though! I've never seen this before. The build log has a single error;

    general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified.

    Any suggestions on what to do next would be gratefully recieved!

    Monday, February 1, 2010 10:41 AM

Answers

  • Something like?

    If this isn't the exact code then you need to post the exact code.

    Otherwise I suggest you get a newer C++ book to learn from.

    The issue here is that the compile and build failed but for some reason VC doesn't notice that the executable doesn't exist. If you select Build->Rebuild Solution then it will delete all the files that it currently has and start the build again. But then you will get compiler errors.

    From your program above I will point out all of the problems with it.

    The most obvious problem is that your include statement is incorrect. You are missing the > from the end. So for it to be correct it should be.
    #include <iostream.h>

    Besides the above iostream.h is a very old header file. It hasn't been in VC++ since VC6 (since 2008 is VC9 then it hasn't been in there for a while). The reason for this is that iostream.h isn't standards compliant so it was removed and replaced with a more compliant version. So if you are learning from something which is telling you to use iostream.h then I would suggest you find something newer.

    If you don't want to change what you are learning from then I will help you out.

    First, replace iostream.h with iostream

    #include <iostream>

    But you must remember that everything inside it is in the std namespace.

    So for the line.

    cout << "hello" << endl;

    You would have to replace it with

    std::cout << "hello" << std::endl;

    A lot of people don't like that, so there are two ways around it. If you want to bring single items into the global namespace then use

    using std::cout;

    Before you use it in your code.

    If you use

    using std::cout;
    using std::endl;

    you can then have your cout line exactly the same as your original program.

    If you want to bring everything in the std namespace into the global namespace then use the following.
    using namespace std;

    Just remember that using this method can give you naming conflicts so you may get weird compiler errors that make no sense. This method is the easiest and most straight forward though.

    So, to put an end to all this rambling. To change your above program in a way which will work.

    #include <iostream>
    using namespace std;

    int main()
    {
      cout << "hello" << endl;
      return 0;
    }

    If you then rebuild your project it should compile link and run with no problems.
    Visit my (not very good) blog at http://c2kblog.blogspot.com/
    • Proposed as answer by Nancy Shao Wednesday, February 3, 2010 7:34 AM
    • Marked as answer by Nancy Shao Monday, February 8, 2010 3:04 AM
    Monday, February 1, 2010 1:31 PM

All replies

  • Something like?

    If this isn't the exact code then you need to post the exact code.

    Otherwise I suggest you get a newer C++ book to learn from.

    The issue here is that the compile and build failed but for some reason VC doesn't notice that the executable doesn't exist. If you select Build->Rebuild Solution then it will delete all the files that it currently has and start the build again. But then you will get compiler errors.

    From your program above I will point out all of the problems with it.

    The most obvious problem is that your include statement is incorrect. You are missing the > from the end. So for it to be correct it should be.
    #include <iostream.h>

    Besides the above iostream.h is a very old header file. It hasn't been in VC++ since VC6 (since 2008 is VC9 then it hasn't been in there for a while). The reason for this is that iostream.h isn't standards compliant so it was removed and replaced with a more compliant version. So if you are learning from something which is telling you to use iostream.h then I would suggest you find something newer.

    If you don't want to change what you are learning from then I will help you out.

    First, replace iostream.h with iostream

    #include <iostream>

    But you must remember that everything inside it is in the std namespace.

    So for the line.

    cout << "hello" << endl;

    You would have to replace it with

    std::cout << "hello" << std::endl;

    A lot of people don't like that, so there are two ways around it. If you want to bring single items into the global namespace then use

    using std::cout;

    Before you use it in your code.

    If you use

    using std::cout;
    using std::endl;

    you can then have your cout line exactly the same as your original program.

    If you want to bring everything in the std namespace into the global namespace then use the following.
    using namespace std;

    Just remember that using this method can give you naming conflicts so you may get weird compiler errors that make no sense. This method is the easiest and most straight forward though.

    So, to put an end to all this rambling. To change your above program in a way which will work.

    #include <iostream>
    using namespace std;

    int main()
    {
      cout << "hello" << endl;
      return 0;
    }

    If you then rebuild your project it should compile link and run with no problems.
    Visit my (not very good) blog at http://c2kblog.blogspot.com/
    • Proposed as answer by Nancy Shao Wednesday, February 3, 2010 7:34 AM
    • Marked as answer by Nancy Shao Monday, February 8, 2010 3:04 AM
    Monday, February 1, 2010 1:31 PM
  • Hi JEFPK,

    Just additional information,  I would suggest you getting started Visual C++ from MSDN with following link:

    http://msdn.microsoft.com/en-us/visualc/default.aspx

    There are lots of material in MSDN website.

    Best Regards,
    Nancy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, February 3, 2010 7:34 AM