-   Linux - Software (
-   -   iostream not found (

krsnachaitanya 02-02-2005 02:12 AM

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

Mega Man X 02-02-2005 02:33 AM

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!

jtshaw 02-02-2005 02:35 AM

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.

krsnachaitanya 02-10-2005 06:38 AM

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

krsnachaitanya 02-10-2005 06:47 AM

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

All times are GMT -5. The time now is 12:52 PM.