g++ won't work on Lion

Go To StackoverFlow.com

6

I have searched and I have received the same answer but I believe mine is different I have Xcode (4.3.2) installed on my mac and when I try to compile my .cpp file it says "command not found" Any suggestions?

How I try to compile;
g++ -o program code.cpp

2012-04-03 23:34
by Ali


12

You need to install the "Command-Line Tools" package through the XCode "Downloads" preferences tab.

2012-04-03 23:41
by duskwuff
Thank you so much - Ali 2012-04-03 23:53
I've been pounding my head against the wall to find out why I could not get g++ or gcc to work. Thank you for this answer +1 - Falcon165o 2012-04-18 13:06


0

open Xcode >> Preferences... >> Downloads and download command line tools

2013-01-19 00:10
by Thiago Baisch


-3

I use

make code

and it finds a compiler, compiles code.cpp and leaves the output in code. And it tells me the name of the compiler... (it is g++).

If you type "which g++" do you find an old alias?

Do you have /usr/bin in your path?

If you do, and /usr/bin/g++ isn't found, check that you've downloaded not only Xcode but the command line utilities that are now a separate download on the developer page.

2012-04-03 23:39
by DRVic
can you show me how can I apply for this specific situation like 'make code code.cpp' or something else - Ali 2012-04-03 23:42
If you have a file by the name code.cpp and you have the command line utilities installed, typing make code invokes g++ -o code code.cp - DRVic 2012-04-03 23:43