Valhalla Legends Archive

Programming => General Programming => C/C++ Programming => Topic started by: Tron on February 20, 2004, 02:19 AM

Title: iostream problems, and compile errors for a simple program!
Post by: Tron on February 20, 2004, 02:19 AM
I don't know why, but i'm getting several compile errors. I'm using Borland Compiler using CMD Prompt if you must know. And also, it also says it can't find my iostream libraries... Which i've noticed are in most C++ Programs. Any help would be great, and thanks for your time!

/*
  This program displays "My First C++ Program... Isn't it great?" to the Standard Output
*/

#include <iostream>

int main ()
{
  std::cout << "My First C++ Program... Isn't it great?";
  return 0;
}
Title: Re:iostream problems, and compile errors for a simple program!
Post by: iago on February 20, 2004, 07:05 AM
Try #include <iostream.h>
Title: Re:iostream problems, and compile errors for a simple program!
Post by: j0k3r on February 20, 2004, 09:01 AM
Yeah, what iago said, and you don't need "std::" in front of cout.
Title: Re:iostream problems, and compile errors for a simple program!
Post by: DVX on February 20, 2004, 09:25 AM
Quote from: iago on February 20, 2004, 07:05 AM
Try #include <iostream.h>

i wouldn't recomend trying to use iostream.h which avoids using the std namespace...  use iostream.  if your compiler isn't finding the libraries look at where it's looking for them at?
additionally, borland's compiler sucks..  and their linker is worse

Quote from: j0k3r on February 20, 2004, 09:01 AM
Yeah, what iago said, and you don't need "std::" in front of cout.

if you are using iostream.h then you don't have too..  but with iostream you must unless you bring cout to local or global scope where you are calling the cout stream
Title: Re:iostream problems, and compile errors for a simple program!
Post by: Skywing on February 20, 2004, 01:11 PM
Are you getting a compile-time or link-time error?

And, yes, you should use <iostream> and std::cout, not <iostream.h> + cout.
Title: Re:iostream problems, and compile errors for a simple program!
Post by: Kp on February 20, 2004, 01:36 PM
Also, you should fix your prototype for main (though I doubt that's causing problems in this particular situation).
Title: Re:iostream problems, and compile errors for a simple program!
Post by: Adron on February 20, 2004, 01:38 PM
Quote from: Tron on February 20, 2004, 02:19 AM
I don't know why, but i'm getting several compile errors. I'm using Borland Compiler using CMD Prompt if you must know. And also, it also says it can't find my iostream libraries... Which i've noticed are in most C++ Programs. Any help would be great, and thanks for your time!

Post the exact error you're getting. Perhaps you're just using an out of date Borland Compiler that doesn't have the right standard C++ libraries?
Title: Re:iostream problems, and compile errors for a simple program!
Post by: iago on February 20, 2004, 02:08 PM
Quote from: Kp on February 20, 2004, 01:36 PM
Also, you should fix your prototype for main (though I doubt that's causing problems in this particular situation).

What's wrong with his prototype for main?  Isn't int main( void ) acceptable?
Title: Re:iostream problems, and compile errors for a simple program!
Post by: Kp on February 20, 2004, 03:42 PM
Quote from: iago on February 20, 2004, 02:08 PMWhat's wrong with his prototype for main?  Isn't int main( void ) acceptable?

That's not what he wrote, and it looks wrong without regard to whether it's standard-compliant! :)
Title: Re:iostream problems, and compile errors for a simple program!
Post by: Tron on February 20, 2004, 04:08 PM
Ok, so i'll post the compile errors i'm getting. Also, i'm using "Windows 2000 Professional Edition". Just in case it regards the OS which I doubt. Anyways here are the errors:

Error E2209 First.cpp 5: Unable to open include file 'iostream'

Error E2090 First.cpp 9: Qualifier 'std' is not a class or namespace name in function main()

Error E2379 First.cpp 9: Statement missing ; in function main()


Borland C++ 5.5.1 (c) 1993, 2000 Borland. And thanks for your help!

Edit: I also have Visual Studio 6.0 compiler, but it's kind of a pain to use because of the workspace you have to create... or maybe i'm just lazy.
Title: Re:iostream problems, and compile errors for a simple program!
Post by: DVX on February 20, 2004, 06:25 PM
Quote from: Tron on February 20, 2004, 04:08 PM
Ok, so i'll post the compile errors i'm getting. Also, i'm using "Windows 2000 Professional Edition". Just in case it regards the OS which I doubt. Anyways here are the errors:

Error E2209 First.cpp 5: Unable to open include file 'iostream'

Error E2090 First.cpp 9: Qualifier 'std' is not a class or namespace name in function main()

Error E2379 First.cpp 9: Statement missing ; in function main()


Borland C++ 5.5.1 (c) 1993, 2000 Borland. And thanks for your help!

Edit: I also have Visual Studio 6.0 compiler, but it's kind of a pain to use because of the workspace you have to create... or maybe i'm just lazy.

well..based on the compile errors it's not able to locate iostream, or the compiler is failing to open the file and include it in which case your compiler is probably not a good one...additionally i believe your compiler is out of date if it thinks std is not a namespace or class...check borland's website for later updates.  also, i wouldn't recomend borland anyways.  if you have microsoft's compiler, use it, IMO it's better than borland, though i would have to argue that gcc is better for more general use and linux-specific programming.
Title: Re:iostream problems, and compile errors for a simple program!
Post by: iago on February 20, 2004, 07:51 PM
Well, it can't open the file iostream so obviously it's not going to find std::.  
Title: Re:iostream problems, and compile errors for a simple program!
Post by: Adron on February 21, 2004, 04:43 AM
Searching a bit on the net, it seems that Borland C++ 5.5 is supposed to support iostream. Maybe you haven't created a project and set the paths correctly in your Borland C++ 5.5? You could try creating a project and setting up the include directories.

Since Borland C++ 5.5 seems to be free, I might download it and try your example out, some time, if i have nothing better to do...
Title: Re:iostream problems, and compile errors for a simple program!
Post by: DVX on February 21, 2004, 02:14 PM
Don't get Borland C++ Builder X
Title: Re:iostream problems, and compile errors for a simple program!
Post by: Adron on February 21, 2004, 02:21 PM
Quote from: DVX on February 21, 2004, 02:14 PM
Don't get Borland C++ Builder X

Because?
Title: Re:iostream problems, and compile errors for a simple program!
Post by: Eli_1 on February 22, 2004, 05:07 PM
I use borland also and used to get that error, from now on when your compiling something, include this in the command line

bcc32.exe -I..\include\ -L..\lib\ codesource.cpp

that should fix it  ::)