PDA

View Full Version : are standard header files like iostream included in development tools?


debo
Jan 15, 2004, 11:46 PM
I know this isn't exactly web development but I thought this was the best place for it.

I wrote a simple program:

#include <iostream>
#include <stdlib>
int main()
{
int i=0;
while (i<10)
{
cout<<"i="<<i<<"\n";
i++;
}
return (0);
}

and when I try to compile it with g++ it gives me errors that indicate that those header files aren't there. I've tried it with the .h on the ends also with the same results.

Doctor Q
Jan 15, 2004, 11:49 PM
Maybe your include path is just missing the right directories. Do you have these files?

/usr/include/gcc/darwin/2.95.2/g++/iostream.h

/usr/include/gcc/darwin/3.1/g++-v3/backward/iostream.h

/usr/include/gcc/darwin/3.3/c++/backward/iostream.h

debo
Jan 16, 2004, 12:06 AM
Yes I have those. Is there anyway to set it so if I just say #include <stdlib> it knows to go to that directory? As opposed to #include "myclass.h" where it would look into the directory that my file was in? Also, is there any way to look at the directories like usr from the Mac HD on the desktop?

Doctor Q
Jan 16, 2004, 01:01 AM
Originally posted by debo
Yes I have those. Is there anyway to set it so if I just say #include <stdlib> it knows to go to that directory? As opposed to #include "myclass.h" where it would look into the directory that my file was in?I think that if you set the CPATH environment variable to a list of directories separated by colons, those directories will be included in the include-file search path. Otherwise, you can use the -I mydirectory or -isystem mydirectory switch on your gcc command line.Also, is there any way to look at the directories like usr from the Mac HD on the desktop? [/B] Yes, in the Finder, select menu choice Go -> Go to Folder... and type the directory path, e.g., /usr or /usr/include.

Fukui
Jan 16, 2004, 01:02 AM
Originally posted by debo
Also, is there any way to look at the directories like usr from the Mac HD on the desktop?
Click the finder, click the "go" menu and choose "go to folder" put in the path to the usr directory ( /usr ) and press enter, it should show up. You could then make a shortcut in the finder sidebar or dock or something to get to it quickly.