Undefined symbol 'cout' in function main ()

Hello,
As you could probably guess I am new to C++ programming. I have a very simple problem that I i tried to look up. My problem is: when i try to compile a .ccp file with the code:

1
2
3
4
5
6
7
8
9
10
// my first program in C++

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}


and i get tge following errors:
Unable to open include file 'iostream'
Namespace name expected
undefined symbol 'cout' in funtion main()
Why is it giving me these errors?
How can I fix these?

I have the Borland compiler 5.5
Windows Vista Ultimate SP2

Any help would be greatly appreciated
Last edited on
Did you follow the borland tutorial for installing correctly?

try this one:

http://www.johnsmiley.com/cis18.notfree/smiley029/smiley029.htm

That page lists the way you add the compiler to environment variables at bottom of page.

very easy, just open up the directory including the borland compiler click in the address window and copy the path, then go to control panel -> system -> advanced, click the environment variables button, scroll down the second box frame, till you see PATH click path and click edit, then a bunch of selected text will pop up in small frame. don't delete this just push the arrow key or something append ';' to the end then paste (ctrl v) the path of borland to the end and then click ok, ok, ok, and your done.
Last edited on
Even though i did not follow it the begining it didn't help when i did it. I double checked to make sure i did everything on that page right to. As for another compiler i tried Microsoft C++ express I believe and it gave me about the same errors.
Last edited on
One,

Try removing the space between #include and <iostream>
No sorry it didn't work.
Whatever you did, you don't have the iostream header. You need to get it. If whatever you are using didn't come with it, either you did something is wrong or something is up.
There's nothing wrong with the code, it's the compiler so ignore foncused and Zhuge.

one nz
did you try bazzy's suggestion?


Do this one last thing if it doesn't work, then unfortunately I won't be able to help you, someone more experienced will have to try and solve your problem.

Go download the DevCpp IDE/Compiler ( it uses a port of MingW, which is the GNU compiler for windows )
http://www.bloodshed.net/devcpp.html

It's quite a nice IDE from what I have seen but I don't use it, personally I use Unix not Windows so I can only give basic advice. DevCpp is free, and should have good resources available.

So go try that please, and post back here if unresolved and someone else might be able to help.
otherwise if it works fine, please mark post as solved.
Last edited on
I just tried out DevCpp and it worked perfectly fine, however the run window didn't stay open.

Not quite sure how to get around this without using some extra code.
see this post:
http://www.cplusplus.com/forum/beginner/1988/

Or what you can do is add DevCpp folder path to path variables and have the command prompt open as well, and just run the executable you make by changing directory to the path where you save the file and type
 ./a.exe 
or windows is probably just
a.exe
There's nothing wrong with the code


I didn't say there was anything wrong with the code. I said it can't find the iostream header. It is probably, as you mentioned, a path variable issue of some kind.
Also Dev-C++ is old...
closed account (S6k9GNh0)
...Though Dev-C++ is old, it should handle this fine and it's a bit *newer* if you simply redirect the IDE to use your own MinGW installation. It's not like the latest Code::Blocks official release is that much better although the SVN or so called Night Releases (given out once a month....wtf) are considered newer releases.

Out of all reality, only small functionality has been added to Code::Blocks over Dev-C++. And although currently Dev-C++ isn't considered to far behind, it's production has completely stopped. It either needs to be updated (I wish I could figure out the Delphi environment he used...) or you need to move on to something that gets updated at least once every two years. Rofl @ C:B.
no problem

Just write

#include<iostraem.h>


bay
Last edited on
I downloaded Dev-C++ and it works perfectly and i get no errors now.
thanks for everybody who helped.
sorry zhuge I didn't read your original post properly.
Topic archived. No new replies allowed.