Just upgraded to Lion from SL, and downloaded xCode from app store.
I go to compile "Hello World" and find that g++ isn't being found. After some searching, I find it in /Developer/usr/bin. I add this to my path, and try to compile, and now its saying it can't find iostream.
Clearly, I missed some key setup step but I don't seem to know what it is. I don't seem to remember any of this when I installed dev tools for previous mac OS upgrades. Anyone else run into this problem or offer some advice?
The code I'm compling is dirt simple obviously, file name helloworld.cpp
#include <iostream>
int main() { std::cout << "Hello World" << std::endl; }
Just trying
g++ helloworld.cpp
and its saying it can't find iostream.h (no such file or directory)
Thanks for your help.
I found the "installers" in 2 packages.
I executed the commands using:
and
I wouldn't use gcc 4.2 from Xcode anyways. It is pretty old and not recommended anymore, especially not if you are writing C++11. For me, and for many other people I am working with, Macports worked really well. To install GCC 4.7 for example, simply set up Macports (http://www.macports.org/install.php), and then type the following command into your shell terminal:
which will install the compiler in your
/opt/local
directory by defaultAfter running the XCode installer that is downloaded by the App Store do the following:
(this is similar to, but simpler than, Simon's solution)
What gets downloaded from the App Store is an installer for Xcode 4.1. You then need to manually run the installer. You should find it in
/Applications
.The Xcode app just installs the IDE environment, if you want to build also from the command line then do the following:
Regards, Simon