Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error occurred compiling gcc from source code

Tags:

gcc

g++

gcc4.4

Right now the gcc and g++ on my ubuntu 15.10 machine is version 5.2.1. I need to install v4.4 of them for some reason. I downloaded the source code of gcc4.4.7 and configure with this:

../configure \
    --disable-checking \
    --enable-languages=c,c++ \
    --enable-multiarch \
    --enable-shared \
    --enable-threads=posix \
    --program-suffix=4.4 \
    --with-gmp=/usr/local/lib \
    --with-mpc=/usr/local/lib \
    --with-mpfr=/usr/local/lib \
    --without-included-gettext \
    --with-system-zlib \
    --with-tune=generic \
    --prefix=$HOME/bin/android_build

I got a makefile and try make but I receive these two errors:

../../gcc/toplev.c:536:1: error: redefinition of ‘floor_log2’
../../gcc/toplev.c:571:1: error: redefinition of ‘exact_log2’

So how to solve this problem? Thanks.

like image 806
darklord Avatar asked Jan 02 '16 18:01

darklord


1 Answers

I tried to install gcc 4.4.7, too, with a newer gcc version. I've seen the same errors as you. According to this bug report, the problem comes from the flag -fno-gn89-inline, which became the default flag for handling inline functions on newer gcc versions. As of gcc 4.3, the default was -fgnu89-inline. So all you need to do, is set the -fgnu89-inline flag when compiling.

I tried this with

CFLAGS='-fgnu89-inline -g -O2' CXXFLAGS='-fgnu89-inline -g -O2' ./configure
make

but I still get the same error. I assume the flags do not get properly forwarded, but I don't know. Then I tried a normal

./configure

and changed the two lines in the Makefile from

CC = gcc
CXX = g++

to

CC = gcc -fgnu89-inline
CXX = g++ -fgnu89-inline

With this, I didn't see the errors any more.

However, I ran into other errors:

@itemx must follow @item

They are caused by a newer version of texinfo, so what you could do is using an older version of texinfo. Maybe you could also fix them by hand, I tried it for one case, but I don't know what I'm doing so I didn't follow this path.

Long story short, I guess you are better off by running a virtual machine or a docker image.

like image 140
pfnuesel Avatar answered Sep 19 '22 16:09

pfnuesel