Reputation: 25
When I try to compile a c++ program in my Mac terminal, I get the following error:
-bash: g++: command not found
but I believe I have all the files I need on my Mac to run the compiler. I have the Developer folder, which contains Xcode in Applications, g++ in the usr/bin folder, and a bunch of other folders.
How can I use these files to install the g++ compiler. Thank you!
Upvotes: 2
Views: 4966
Reputation: 366073
houbysoft's answer above is correct, but the OP needs a little more detail.
The basic idea is that you need the "Command Line Tools" environment installed. But the name for that environment, and how you install it, has changed multiple times over the years. So, houbysoft's steps work for 4.3.3, but not for 3.2.6.
In the 3.2 era, the tools were called "UNIX Development". And, rather than being downloaded and installed from within Xcode, they came as part of the Xcode mpkg and were installed as part of the initial Xcode install. In most versions, there was a checkbox named "UNIX Development", usually checked by default, but in some versions it was a separate step. Looking at the "Xcode 3.2.6 and IOS SDK 4.3" disk image currently available from Apple, it's a checkbox. Anyway, that's the only officially-supported way to get them, but lots of other ways work… Here are your options:
Upvotes: 3
Reputation: 33430
Assuming you have the latest Xcode, go to Xcode Preferences, Downloads, and click on the Install
button next to Command Line Tools
. This should install and put everything into your PATH
automatically.
Upvotes: 4
Reputation: 89559
If everything is installed correctly, it sounds like all you need to do is get your "PATH
" environment variable modified.
This closely related SuperUser question should provide the answers you need, at least if you're running under Snow Leopard. Here's another question about setting environment variables for Lion.
Upvotes: 0