If you install GCC from source just make sure you don't install it to /usr
and it won't mess anything up. If you install it as your own user, not root
, then there is zero chance of messing up the system.
See http://gcc.gnu.org/wiki/InstallingGCC for the almost-idiot-proof minimal configuration.
I have various versions built as my user and installed in ~/gcc/4.X
for various X.
The only thing to be aware of using that set up is that the shared libraries for the new version aren't in the dynamic linker's default search path, so you need to use LD_LIBRARY_PATH
or some other solution to ensure executables find the libs from 4.8, see the libstdc++ FAQ and the page it links to in the manual
I use a wrapper script call g++11
which simply calls the new version of GCC with -std=gnu++11
and passes a flag to the linker telling it to set the path to the 4.8 libs in the executable:
$HOME/gcc/4.8/bin/g++ -Wl,-rpath,$HOME/gcc/4.8/lib64 -std=gnu++11 -Wall -Wextra -g "$@"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…