Installing gcc 4.7.0 from source on Linux Mint 12.

Posted: May 12, 2012. At: 3:00 PM. This was 5 years ago. Post ID: 3798

Install gcc from source on Linux Mint 12

After downloading the source tarball for the gcc 4.7.0 release, and unpacking the tarball, enter the source directory:

cd gcc-4.7.0/

Then we need to create an empty folder under the gcc-4.7.0/ folder to perform the actual build.

mkdir mintbuild

Then enter this folder:

cd mintbuild

After that; we need to run the configure script to prepare the source for compilation. This is the configure string I am using. I typed gcc -v with my old version and this will give you the configure string used to build the existing gcc installation. You can copy and modify this to suit.

../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7' --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr \
--program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext\
 --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu\
 --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686\
 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu

I had to install three packages to complete the configure step. This command will install them: sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev.

Due to my Linux distribution being 64bit, I got this error upon running make.

/usr/include/features.h:323:26: fatal error: bits/predefs.h: No such file or directory

The required libraries are found in the libc6-dev-i386 package.

sudo apt-get install libc6-dev-i386

This error was due to not having installed the libraries required for a 32bit build with gcc.

The last error I got:

/usr/bin/ld: cannot find crti.o: No such file or directory

was easily fixed with this command.

sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64

Then I typed sudo make install and gcc was installed into /usr. I installed it with the –program-suffix=-4.7 parameter to the configure script, therefore I have to type gcc-4.7 to use it. I just tested it out and it works perfectly.

-14:53:55-- gordon@deusexmachina [~/Downloads/gcc-4.7.0/mintbuild]$ gcc-4.7 -v
Using built-in specs.
COLLECT_GCC=gcc-4.7
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../configure -v --with-pkgversion='Ubuntu/Linaro 4.7' --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.0 (Ubuntu/Linaro 4.7) 
-14:53:57-- gordon@deusexmachina [~/Downloads/gcc-4.7.0/mintbuild]$

No comments have been made. Use this form to start the conversation :)

Leave a Reply