Вопрос

I'm running debian wheezy and wanted to upgrade from GCC 4.7.2 to GCC 4.9.0.

As per these instructions I installed libgmp-dev, libmpfr-dev and libmpc-dev (my package manager gave me versions 2:5.0.5+dfsg-2, 3.1.0-5 and 0.9-4 respectively) and ran the following to compile gcc (note that in my case it was 4.9.0 instead of 4.6.2):

tar xzf gcc-4.6.2.tar.gz
cd gcc-4.6.2
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.6.2/configure --prefix=$HOME/gcc-4.6.2 
make
make install

I now have a objdir directory full of stuff, but where is g++, and where should I put this directory?

I'm guessing I should move it to usr/local and add something to my PATH variable, but I don't know what exactly, and how to make sure it is searched before my old gcc install.

Это было полезно?

Решение

After doing these commands (note the --prefix option of configure)

$PWD/../gcc-4.9.0/configure --prefix=$HOME/gcc-4.9.0 
make install

the new gcc will be installed in $HOME/gcc-4.9.0 directory (there should be subdirectories like bin, lib, share inside it).

Full path to gcc will be $HOME/gcc-4.9.0/bin/gcc, and g++ (which is symlink to gcc) will be here: $HOME/gcc-4.9.0/bin/g++.

There can be no separate g++ in objdir because gcc compiler driver implements drivers for several languages; the mode (C or C++) is selected based on argv[0] (name of binary, which was used to run driver: gcc or g++; this mode also affects linking flags) and on source file extensions (gcc accepts both C and C++ programs as input for compilation into object files). So, g++ may be generated as symlink by make install, and the place to store generated symlink is $prefix/bin.

After building the GCC and installing it in the $HOME/gcc-4.9.0 directory, you can use it; but default system gcc will be not updated. Update of distributive gcc should be done via distributive tools (apt, dpkg-build, etc). Current prebuild version of system-wide gcc for Wheezy is 4.7.2, 4.8.2 for Jessie and Sid and 4.9-2 for "Experimental".

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top