Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

debo

macrumors regular
Original poster
Jan 9, 2004
180
0
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

Administrator
Staff member
Sep 19, 2002
39,835
7,635
Los Angeles
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

macrumors regular
Original poster
Jan 9, 2004
180
0
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

Administrator
Staff member
Sep 19, 2002
39,835
7,635
Los Angeles
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

macrumors 68000
Jul 19, 2002
1,630
18
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.