fatal error: IOStream: No such file or directory

I know this is a topic well discussed, but I have looked through this and other forums, but others mistakenly use .h. I am running Ubuntu with G++ 4.5.2.

My code:
#include <iostream>
using namespace std;

int main()
{
cout << "Hello world." << endl;
return -1;

}

I compile with:
G++ HelloWorld.cpp

My error is:
HelloWorld.cpp:1:20: fatal error: IOStream: No such file or directory
compilation terminated.

I can compile fine with both geany and eclipse IDE, but I am practicing with programming with terminal. Since it compiles with the IDE, I am leaning toward g++ and libraries being installed correctly. I have the iostream file in /usr/include/c++/4.5/iostream directory.

I would appreciate any help because I have struggling with this for a couple of days now.
Hi scratch509 I gust go throughout the code and I want to explain something:
In the main function when u return it u return 0 which is an interger that means return nothing.
If u return -1 in any function that means that u are logically that thear is an error.
I hope that u understand .
To build it type:
 
 make HelloWorld
closed account (zb0S216C)
ARWA wrote:
In the main function when u return it u return 0 which is an interger that means return nothing.

You couldn't be anymore wrong. void means you return nothing. When he/she returns -1, he/she returns -1, not 0.

ARWA wrote:
If u return -1 in any function that means that u are logically that thear is an error.

What if I had a method that returned -1 on a successful call? It may not be common to return -1 on a successful method call, but never assume such things; everybody's coding style is different.

Scratch, a glance at your code reveals no apparent errors. However, considering you're on Ubuntu, installation is different than Windows. It would be beneficial to post this question in the Unix/Linux section of this forum.

Wazzak
Last edited on
You might have a problem with case sensitivity.
The header is called iostream, not IOStream. Likewise, the compiler is called g++, not G++.
Thanks everyone for the replies. I figured out my issue here. I don't even want to admit it, but it does help if you compile the same file you are editing. I did take the uppercase and the -1 comment onboard though and will remember it.
I have a nearly similar issue on my MacOSX computer, but there it doesn't even compile with an IDE. That is my next thing to figure out.

You guys are awesome.
Topic archived. No new replies allowed.