Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 02-02-2005, 02:12 AM   #1
LQ Newbie
Registered: Jan 2005
Posts: 16

Rep: Reputation: 0
iostream not found


I am using fedora core 2. I am unable to compile cpp programs. I wrote a sample program and I am unable to compile it, as gcc reports that iostream not found. Please help me in this regard. How should I configure my gcc. Where does gcc search for the header files.

I would also need to use ncurses for the program that I intend to write later. Please elaborate or else atleast lead me to the source where can I get answers for that..

King Krsna
Old 02-02-2005, 02:33 AM   #2
Mega Man X
LQ Guru
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
Hi krsnachaitanya!

Please, always post the code you are trying to compile and the commands you are using to compile your program. If it's a c program, you've use this command:

gcc -o executable sample.c

If it's a c++ program, you will use this:

g++ -o executable sample.cpp

Basically, g++ will not compile c code and gcc will not compile c++ code. Also, there could be a problem with your code. You are most likely:

- Forgetting to use the line "using namespace std" or "std::cout" in your program.

Again, there could be a thousand of different reasons. Try posting always, a detailed things of what you are doing, how you doing and what error messages you got.

Good luck and have a nice day!
Old 02-02-2005, 02:35 AM   #3
Senior Member
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
I'm not sure where specifically the headers would be on Fedora. However, usually they are in /usr/lib/gcc-lib/<arch-type>/<gcc version>/include/g++-v<version major num>/.

For example: /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5/include/g++-v3/ is the directory they are in on my Gentoo server running GCC/G++ 3.3.5.

I'm guessing your having a problem because Fedora has a seperate GCC and G++ package and you only installed the GCC package. Yes, g++ is part of the Gnu Compiler Collection. However, often the base gcc package for linux distributions only includes the C compiler since it is typically all you need for a basic linux system.

Btw... locate iostream or find / -name "iostream" will search for file system for the iostream file. Remember that C++ headers no longer have .h's after them. Locate will only work if you have a locate database and it has been updated since you installed your gcc/g++ package.
Old 02-10-2005, 06:38 AM   #4
LQ Newbie
Registered: Jan 2005
Posts: 16

Original Poster
Rep: Reputation: 0
Sorry for the delayed reply, my piece of code and the sample output

sorry for the delayed reply. I am posting my code as well as a sample of the output error. This code worked properly on other machines. I guess theproblem is with the configuration and not with the code. Please help me out..

using namespace std;
struct temp
int a;
int aa;

class A
int a;
int aa;
struct temp getvar();
void setvar(int);
int* getaddrofa();
int* getaddrofaa();
class B : public A
int b;
int bb;
void getvar();

struct temp A :: getvar ()
struct temp tmp;
tmp.a = a;
tmp.aa = aa;
return tmp;

void A :: setvar ( int val )
a = val;
aa = 100;

int* A :: getaddrofa()
return &a;

int* A :: getaddrofaa()
return &aa;

int main ()
class A AObj;
cout << "starting address of AObj is " << &AObj << endl;
cout << "starting address of AObj.a is " << AObj.getaddrofa() << endl;
cout << "starting address of AObj.aa is " << AObj.getaddrofaa() << endl;
AObj.setvar ( 10 );
cout << "The value of a is " << AObj.getvar().a << endl;
cout << "The value of b is " << AObj.getvar().aa << endl;
return 0;

and the output that i got when executing it with is
g++ first.cpp

The sample output that got is like this:

$ g++ first.cpp
first.cpp:1:19: iostream: No such file or directory
first.cpp: In function `int main()':
first.cpp:56: error: `cout' undeclared (first use this function)
first.cpp:56: error: (Each undeclared identifier is reported only once for each
function it appears in.)
first.cpp:56: error: `endl' undeclared (first use this function)

Please help me out.. I am not able to make any progress without being able to rectify these simple error messages
Old 02-10-2005, 06:47 AM   #5
LQ Newbie
Registered: Jan 2005
Posts: 16

Original Poster
Rep: Reputation: 0
hi jtshaw,

I tried locating the iostream file on my system using the command find / -name iostream.

It showed the location of the files as /usr/include/g++-3/iostream

and not in /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5/include/g++-v3/

so is this the problem. How should I tell the compiler that it should look under /usr/include/g++-3/iostream instead?
Please help me out..
Thanks a lot for your support.

k. krishna chaitanya


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
g++ compiler and iostream.h BACTRATE Mandriva 5 07-26-2009 04:12 AM
gcc vs. g++ -> iostream lib found vs. not found CooManChu Linux - General 1 12-11-2004 09:20 AM
where is iostream invisibleghost Programming 2 10-24-2004 01:30 PM
iostream, or stdio? jpc82 Programming 7 11-05-2003 08:10 PM
g++ why cant i #include \<iostream\> ??? qwijibow Programming 4 10-03-2003 07:17 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:05 AM.

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