Results 1 to 5 of 5
  1. #1

    Member Since
    Feb 20, 2011
    g++ fstream in Mac OS X 10.6

    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?

    Thank you

  2. #2

    Member Since
    May 10, 2012
    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?

  3. #3

    vansmith's Avatar
    Member Since
    Oct 19, 2008
    2012 13" MBP (2.5 i5, 8GB)
    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>.
    Important Links: Community Guidelines : Use the reputation system if you've been helped.
    M-F Blog :: Write for the blog
    Writing a Quality Post

  4. #4

    Member Since
    May 10, 2012
    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?

  5. #5

    Member Since
    May 10, 2012
    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!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. C++ Beginner simple fstream question
    By Kenya253 in forum OS X - Development and Darwin
    Replies: 0
    Last Post: 10-04-2009, 06:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts