0

As the title states, I am having problems compiling my program, and the error is C++11 specific. Is there some way I can go back to the compiler I had on 12.04? Do I need to install another version of g++ and then use that? I googled around but I cannot find what shipped with 12.04. I just need an older alternative to the compiler 14.04 comes with.

Thanks!

user300458
  • 2,108
  • 2
  • 17
  • 20
Mr. Fegur
  • 325
  • 1
  • 2
  • 7

2 Answers2

1

You can install g++ 4.4, 4.6 or 4.7 from the package g++-4.X. (Then compile your program with g++-4.X instead of just g++.)

For reference, the default g++ version in Ubuntu 12.04 is 4.6.

muru
  • 197,895
  • 55
  • 485
  • 740
fkraiem
  • 12,555
  • 4
  • 35
  • 40
  • I noticed I had 4.6 installed, but trying to change it to use 4.6 compiler by default, using the method listed in the question:

    link

    did not work. I manually changed the symbolic link in /usr/bin/ to point to g++ and that worked fine. So problem solved.

    – Mr. Fegur Sep 29 '14 at 18:15
  • Apparently /usr/bin/g++ is just a symlink to /usr/bin/g++-4.8, so you can try to make it point to g++-4.6 instead (i.e., sudo ln -snf /usr/bin/g++-4.6 /usr/bin/g++). It could cause some problems if you ven compile system things like kernel modules, though, so I wouldn't recommend it (but since it's easily undoable, I guess it doesn't really hurt to try). – fkraiem Sep 29 '14 at 18:20
  • There was a type in my post. I did exactly what you said and I can compile my program now. – Mr. Fegur Sep 29 '14 at 22:37
0

You can continue using the new g++, and specify the standard to be used:

-std=
   Determine the language standard.   This option is currently only
   supported when compiling C or C++.

For 12.04, man g++ says:

gnu++98
   GNU dialect of -std=c++98.  This is the default for C++ code.

So compile your code with:

g++ --std=gnu++98

However, man g++ on 14.04 says:

gnu++98
gnu++03
   GNU dialect of -std=c++98.  This is the default for C++ code.

So it would look like the default standard hasn't changed.

Are you sure of the source of your error?

muru
  • 197,895
  • 55
  • 485
  • 740