g++ fstream in Mac OS X 10.6

Joined
Feb 20, 2011
Messages
1
Reaction score
0
Points
1
Hello,

I'm using Mac OS X 10.6 and installed Xcode 3.X. I'm actually working on a C++ project and try to use g++ to build the project.

I include ifstream but it prompted an error that 'can't find file or directory' ifstream somehow. I thought stdio exist somewhere that include <iostream> works.

Is there any one can help me out?

Adam
Thank you
 
Joined
May 10, 2012
Messages
3
Reaction score
0
Points
1
same problem

I have the same problem with xcode 3.1.4 on Os X 10.5. No idea how to solve it. I've been trying to figure out if it's possible to have a compiler installed, but not have The C Language installed?
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
The language support is handled by the compiler. However, the header files are separate but should be included. You can check to see if it's there by looking in /usr/include/c++/<gcc version number>.
 
Joined
May 10, 2012
Messages
3
Reaction score
0
Points
1
files

Thanks for the reply. That folder exists, and there are a number of things there, such as "string" and "iostream" (both ASCII C++ program text), but, e.g., there is no ifstream file.

I checked a working installation of g++ on a Linux machine, and it has roughly the same files in the corresponding folder (i.e., no ifstream), yet it allows me to #include<ifstream>. I located, and no file called ifstream seems to exist on that Linux system, so I assume this header file must be located inside another file.

#include<string>, #include<iostream> both work on my system, so the compiler seems to know where some things are, yet #include<ifstream> still does not work. I feel like there must be something extremely basic I don't know (not an unreasonable supposition, since I'm a beginner), and my googling has been no help at all (probably because I'm using the wrong search terms and I can't think of better ones). Is there some sort of path I could be setting?
 
Joined
May 10, 2012
Messages
3
Reaction score
0
Points
1
figured it out

Okay, apparently ifstream and ofstream are both contained inside fstream. So when I include fstream, rather than *ifstream*, I am now able to create a variable of type ifstream. I don't know how to do anything with it yet, so that's as far as I've gotten, but no compile errors at least....

Thanks for the help!
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top