0

instead of g++ command O have to type g++-6 -v how do i fix this so that g++ command to g++-6

enter image description here

this is giving me problem compiling native extensions from ruby and might be trouble for other programs too

You'reAGitForNotUsingGit
  • 14,669
  • 9
  • 48
  • 83
Hector
  • 13
  • 1

2 Answers2

0

Work around.

Open your .bashrc:

gedit ~/.bashrc

Add this line to the end of the file:

alias g++='g++-6'

Then source your .bashrc:

source ~/.bashrc

One liner:

echo "alias='g++=g++-6'" >> ~/.bashrc; source ~/.bashrc
Raphael
  • 7,985
  • 5
  • 34
  • 51
  • @Hector - If it answered your question please upvote the answer and accept it as a token of thanks. – Raphael Sep 09 '16 at 20:54
  • This doesn't actually solve it. Well... it *does* but not enough so. An alias is not a sufficient fix for something like this. – Slava Knyazev Sep 09 '16 at 21:31
0

A more proper fix for this would be to make a symbolic link for g++-6 to g++. This will ensure compatibility with many installers and other applications.

To do this:

sudo ln -s $(type g++-6 | grep -oE '[^ ]+$') /usr/bin/g++

This will get the path to g++-6 and create a symbolic like using it to /usr/bin/g++

Slava Knyazev
  • 1,028
  • 4
  • 11
  • 25