LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-18-2003, 03:38 AM   #1
hfawzy
Member
 
Registered: Aug 2002
Location: Egypt
Distribution: Debian Sarge, Slackware 10.0
Posts: 163

Rep: Reputation: 30
gcc3 and RH 8


Hi,
I have Redhat 8, and want to compile my C++ programs using g++.
But when, for instance, I try to compile this program (using g++ test.cpp -o test) :
Code:
#include <iostream>
int main() {
        cout << "hi";
return 0;
}
It prints out this error:
Quote:
test.cpp: In function `int main()':
test.cpp:3: `cout' undeclared (first use this function)
test.cpp:3: (Each undeclared identifier is reported only once for each function
it appears in.)
I think the problem here is that it can't find iostream.h. I did a locate for iostream.h and I found all gcc header files at /usr/include/c++/3.2.
How can I solve this problem ?
Thank you
PS: gcc 3 takes too long compiling : 7 secs to compile this tiny program above. but when i had mandrake and gcc 2.96 it took 0.5 seconds compiling it... strange?
 
Old 04-18-2003, 05:34 AM   #2
miknight
Member
 
Registered: Oct 2002
Location: Sydney, Australia
Distribution: Gentoo, Ubuntu, Debian
Posts: 184

Rep: Reputation: 30
#include <iostream>

using namespace std;

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



You need to look for cout within the std namespace if you include the iostream lib like that.... shouldn't this thread be in programming?
 
Old 04-18-2003, 05:47 AM   #3
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
or just do this:

#include <iostream.h>

wouldn't that solve the problem as well?

It works on my machine .... i have redhat 7.3
-twantrd
 
Old 04-20-2003, 04:51 AM   #4
miknight
Member
 
Registered: Oct 2002
Location: Sydney, Australia
Distribution: Gentoo, Ubuntu, Debian
Posts: 184

Rep: Reputation: 30
Yes, but that way is not ANSI C++ compliant, and it's possible it may not work on some ANSI C++ compilers.
 
Old 04-20-2003, 04:04 PM   #5
nakkaya
LQ Guru
 
Registered: Jan 2003
Location: Turkey&USA
Distribution: Emacs and linux is its device driver(Slackware,redhat)
Posts: 1,398

Rep: Reputation: 45
or another option use cout like that

std::cout<<"hello world\n";
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gcc3.3.1 manoj142 Linux - Software 3 10-21-2005 09:29 AM
has any one upgraded from gcc3.3.4 to gcc3.4.3? mojarron Slackware 2 03-20-2005 11:44 AM
gcc3.3 + kernel ??? trey85stang Slackware 0 03-22-2004 08:38 AM
getting gcc3.2.2-5 harun_acs Linux - Software 1 03-17-2004 09:18 AM
RedHat 8 and gcc3.2-7 necromancer Linux - Newbie 0 02-28-2003 07:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration