Xcode Failed to Install G++

Joined
Jan 19, 2012
Messages
14
Reaction score
0
Points
1
Hi all.

Just days ago I installed Xcode from the App Store, but then when I went to the terminal prompt I discovered that the g++ command wasn't there. What gives? Everyone tells me it's supposed to be there, and I need it...

Any help would be greatly appreciated. Thanks!
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
It should be there but you wouldn't be the first person missing the links. Execute the following commands to set the links:
Code:
sudo ln -s /Developer/usr/bin/llvm-g++-4.2 /usr/bin/g++
Code:
sudo ln -s /Developer/usr/bin/llvm-gcc-4.2 /usr/bin/gcc
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Oops, that was my inability to copy and paste. ;)

Commands fixed.
 
OP
S
Joined
Jan 19, 2012
Messages
14
Reaction score
0
Points
1
The line to enter g++ didn't seem to work. It gave me a very grave warning that I was probably about the screw up my machine and then asked me for my password. I entered it, pressed enter, and was unceremoniously returned to the prompt with no sign of success or failure. Entering in the line again says, "Line exists." But here's the thing: it still tells me no g++ command exists.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
When it completes, you don't get a warning or success message. In fact, having nothing printed back is a good sign.

What does the following return?
Code:
echo $PATH
 
OP
S
Joined
Jan 19, 2012
Messages
14
Reaction score
0
Points
1
It returns:

Code:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Well, /usr/bin is in your PATH (as it should be) and there is a symlink there called "g++" to the g++ binary installed by Xcode. Do you at least have success executing llvm-g++-4.2 from /Developer/usr/bin/?
 
OP
S
Joined
Jan 19, 2012
Messages
14
Reaction score
0
Points
1
Is "llvm-g++-4.2" a command that needs to be run from a specific directory? (You're dealing with a guy who has lots of DOS experience but virtually zero Unix command line experience. I have to look up how to change directories...)
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
cd = change directory.

You can simply execute /Developer/usr/bin/llvm-g++-4.2 or "cd" into /Developer/usr/bin and then type "./llvm-g++-4.2" (without the quotes).
 
OP
S
Joined
Jan 19, 2012
Messages
14
Reaction score
0
Points
1
It says "no such file or directory" when I enter "/Developer/usr/bin/llvm-g++-4.2".

Would it make any difference to say I have Xcode 4.3?
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Yes, absolutely. Xcode 4.3 doesn't install the tools by default. Go to Xcode > Preferences > Downloads > Components > install "Command Line Tools."
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top