Compiling error with g++ 4.9 on OSX Yosemite

466 Views Asked by At

Recently I installed the new version of gcc (4.9) on OSX Yosemite, following the steps that I found on:

https://wiki.helsinki.fi/display/HUGG/Installing+the+GNU+compilers+on+Mac+OS+X

But when I try to compile a simple "Hello World" program, the compiler print the next:

fatal error: iostream: No such file or directory 
compilation terminated.

It seems to be a easy problem to solve, but I'm new using this OS. So I don't want to mess it up.

Thank you!.


The code is just a "Hello World" :

#include <iostream> 
#include <stdio.h>

using namespace std;

int main()
{
    cout << "Hello World" << endl;  
    return 0;
}

Then I complile with g++ on Terminal like this: g++ hw.cpp -o hw.o

The the result is: fatal error: iostream: No such file or directory

1

There are 1 best solutions below

3
Nooble On

You are probably using gcc instead of g++, try doing the following:

g++ your_source_file.cpp -std=c++11