5

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.

pfnuesel
  • 14,093
  • 14
  • 58
  • 71
darklord
  • 5,077
  • 12
  • 40
  • 65
  • Did you get this resolved? Since you've not got an answer for over a month, I'll guess that the answer is 'yes — I got this resolved sufficiently, or circumvented the problem by downloading a pre-compiled version'. – Jonathan Leffler Feb 05 '16 at 15:37
  • I just installed an older version ubuntu on virtual machine – darklord Feb 05 '16 at 17:40

3 Answers3

7

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.

pfnuesel
  • 14,093
  • 14
  • 58
  • 71
1

Try ../configure CFLAGS='-fgnu89-inline -g -O2' ...

It worked for me.

Huangjie
  • 11
  • 1
  • 1
0
/*                    //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;
}
*/
oiio
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 08 '23 at 08:29