Home Closet Building gcc from source

Building gcc from source

by admin

The gcc set of compilers is rapidly developing and quite often there appear some new features (for example, from the new C++ standard)that you want to try today but don’t want to wait for the release. There is only one way out – to build the compiler from source. Here I will share my experience in this.
1. First, let’s drain sources from SVN’a :
svn checkout svn://gcc.gnu.org/svn/gcc/trunk gcc
Waiting. On my connection I had to wait about 30 minutes.
2. now do this :
cd gcc
/configure --enable-languages=c, c++, java

Let me explain the last line: here we put a comma separated list of compilers we need. I put here what I need (by the way, there is a go branch in gcc, a guide to build it here )
On my Fedora 12 this script was giving out curses like :
configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.
No problem! Put the necessary packages :
yum install gmp mpfr mpc gmp-devel mpfr-devel libmpc libmpc-devel
The configuration script should now run normally
3. Trying to run make, but we get something like this :
gcc: gengtype-lex.c: No such file or directory
gcc: no input files

Treat it this way :
yum install flex
If it still won’t build, you can try doing make distclean and then re-run the configure script.
4. let it build for a few hours and then type :
make install
and use the fresh gcc!

You may also like