Reputation: 5167
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.
Upvotes: 5
Views: 4613
Reputation: 1
/* //toplev.h 注释下面两个函数 Annotate the following two functions
extern inline int
floor_log2 (unsigned HOST_WIDE_INT x)
{
return x ? HOST_BITS_PER_WIDE_INT - 1 - (int) CLZ_HWI (x) : -1;
}
extern inline int
exact_log2 (unsigned HOST_WIDE_INT x)
{
return x == (x & -x) && x ? (int) CTZ_HWI (x) : -1;
}
*/
Upvotes: 0
Reputation: 11
Try
../configure CFLAGS='-fgnu89-inline -g -O2' ...
It worked for me.
Upvotes: 1
Reputation: 15300
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.
Upvotes: 7