LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Build GCC 4.6.2error on i686-pc-linux-gnu machine (http://www.linuxquestions.org/questions/linux-newbie-8/build-gcc-4-6-2error-on-i686-pc-linux-gnu-machine-929660/)

Derek stallone 02-16-2012 04:47 AM

Build GCC 4.6.2error on i686-pc-linux-gnu machine
 
I chose a gcc 4.6.2. I downloaded gcc-4.6.2.tar.bz2 from here ftp://ftp.gnu.org/gnu/gcc/gcc-4.4.6/ and made the following steps:
Code:

stallone@stallone-desktop:~$mkdir build-gcc
stallone@stallone-desktop:~$cd build-gcc/
stallone@stallone-desktop:~/build-gcc$sudo /usr/src/gcc/gcc-4.6.2/configure --prefix=/usr/gcc-4.6.2/  --with-gmp=/usr/local/gmp --with-mpfr=/usr/src/mpfr --with-mpc=/usr/local/mpc --with-ppl=/usr/local/gmp --with-cloog=/usr/local  LDFLAGS="-L/usr/local/lib -Xlinker -R/usr/local/lib" CONFIG_SHELL=/bin/bash -enable-languages=c,c++,fortran
stallone@stallone-desktop:~/build-gcc$make

And after makeing,I have some errors

Code:

In file included from /usr/src/gcc/gcc-4.6.2/gcc/cp/except.c:912:0:
/usr/src/gcc/gcc-4.6.2/gcc/cp/cfns.gperf:101:1: error: ‘gnu_inline’ attribute present on ‘libc_name_p’
/usr/src/gcc/gcc-4.6.2/gcc/cp/cfns.gperf:26:14: error: but not here
make[3]: *** [cp/except.o] Error 1
make[3]: Leaving directory `/home/stallone/build-gcc/gcc'
make[2]: *** [all-stage2-gcc] Error 2
make[2]: Leaving directory `/home/stallone/build-gcc'
make[1]: *** [stage2-bubble] Error 2
make[1]: Leaving directory `/home/stallone/build-gcc'
make: *** [all] Error 2

What did I do wrong and how to fix it?

John VV 02-16-2012 10:11 PM

first 4.6.2 is SO NEW that a lot of software will not YET build with it .At least not with out hacking the program.

also there are WAY more programs that need to be installed besides just gcc
you need to install the whole development tree

you normally do that with your package manager
seeing as you do not say WHAT this operating system is ..........
We do not know what package manager you have installed
a debian based will be "apt-get"
and a redhat /fedora based OS will be " yum"

then there are a few others for different OS's


also you really do NOT want to build software on your desktop
that is not even a good idea on MS windows and is still a bad idea on a linux OS
us your HOME folder
/home/YourUserName/ProgramName

Derek stallone 02-16-2012 10:17 PM

Quote:

Originally Posted by John VV (Post 4604641)
first 4.6.2 is SO NEW that a lot of software will not YET build with it .At least not with out hacking the program.

also there are WAY more programs that need to be installed besides just gcc
you need to install the whole development tree

you normally do that with your package manager
seeing as you do not say WHAT this operating system is ..........
We do not know what package manager you have installed
a debian based will be "apt-get"
and a redhat /fedora based OS will be " yum"

then there are a few others for different OS's


also you really do NOT want to build software on your desktop
that is not even a good idea on MS windows and is still a bad idea on a linux OS
us your HOME folder
/home/YourUserName/ProgramName

Thank you very much! John!

KenJackson 02-16-2012 10:43 PM

A few years back, I used to regularly compile GCC to make cross compilers for MinGW (Windows) and AVR microcontroller targets. But I haven't been able to get it to compile since they started using the MPFR and CLooG math libraries.

But I just found a page that explains how to build a combined tree. This might solve it for me, when I get to it.

But it seems like it should be a little simpler for you, since you aren't building a cross compiler and don't need newlib.

Derek stallone 02-16-2012 11:18 PM

By the way, my OS is ubuntu 10.04LTS
after type uname -a ,here is the result.

stallone@stallone-desktop:~$ uname -a
Linux stallone-desktop 2.6.32-33-generic #70-Ubuntu SMP Thu Jul 7 21:09:46 UTC 2011 i686 GNU/Linux

Derek stallone 02-16-2012 11:23 PM

Quote:

Originally Posted by KenJackson (Post 4604655)
A few years back, I used to regularly compile GCC to make cross compilers for MinGW (Windows) and AVR microcontroller targets. But I haven't been able to get it to compile since they started using the MPFR and CLooG math libraries.

But I just found a page that explains how to build a combined tree. This might solve it for me, when I get to it.

But it seems like it should be a little simpler for you, since you aren't building a cross compiler and don't need newlib.

By the way, my OS is ubuntu 10.04LTS
after type uname -a ,here is the result.

stallone@stallone-desktop:~$ uname -a
Linux stallone-desktop 2.6.32-33-generic #70-Ubuntu SMP Thu Jul 7 21:09:46 UTC 2011 i686 GNU/Linux
Thanks KenJackson

John VV 02-16-2012 11:50 PM

I my self do not use ubuntu
but it uses apt-get
now the 4.6 gcc i believe REQUIRES a newer version of glibc than is in the long term support 10

you might NOT be able to easily build gcc.4.6.2 on the older ubuntu 10.04LTS

from the ubuntu forums - do this
http://ubuntuforums.org/index.php
Code:

sudo apt-get install build-essential

knudfl 02-17-2012 10:06 AM

Ubuntu 10.04 Lucid will do OK for compiling gcc-4.6.2,
but : gcc-4.6.2 is for the code of tomorrow. Ref. post #2.
The default gcc/g++ version 4.4.3 will probably be sufficient for all your needs :
sudo apt-get install g++-4.4
I.e. you can can have as many versions of gcc / g++ as you want,
installed at the same time. ( All with unique file names.)
Use with, example : export CC=gcc-4.4 CXX=g++-4.4 && <other-command>.


Prerequisites for gcc-4.6.2 :
1) sudo apt-get install libppl0.10-dev

2) gmp-4.3.2 mpfr-3.1.0 mpc-0.9 unpacked into the gcc-4.6.2/ source.
Rename to a) gmp/ b) mpfr/ c) mpc/

3) A valid configure line :
../gcc-4.6.2/configure --prefix=/usr/local/gcc462 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++,fortran --disable-multilib --with-system-zlib --with-mpfr-include=$(pwd)/../gcc-4.6.1/mpfr/src --with-mpfr-lib=$(pwd)/mpfr/src/.libs
( A hideaway location like /usr/local/gcc462/ is a must,
in order not to conflict with the system gcc, libgcc etc.)
Now you can do 'make' : There are no errors on Ubuntu 10.04, i686.

( Example "build gcc"
http://www.linuxquestions.org/questi...-5-1-a-842567/ )

/usr/local/gcc462/bin/gcc, /usr/local/gcc462/bin/g++ :
Suggest : Make symlinks to /usr/bin/ gcc462 g++462

.

Derek stallone 02-17-2012 06:16 PM

Quote:

Originally Posted by knudfl (Post 4605105)
Ubuntu 10.04 Lucid will do OK for compiling gcc-4.6.2,
but : gcc-4.6.2 is for the code of tomorrow. Ref. post #2.
The default gcc/g++ version 4.4.3 will probably be sufficient for all your needs :
sudo apt-get install g++-4.4
I.e. you can can have as many versions of gcc / g++ as you want,
installed at the same time. ( All with unique file names.)
Use with, example : export CC=gcc-4.4 CXX=g++-4.4 && <other-command>.


Prerequisites for gcc-4.6.2 :
1) sudo apt-get install libppl0.10-dev libmpfr-dev

2) gmp-4.3.2 mpfr-3.1.0 mpc-0.9 unpacked into the gcc-4.6.2/ source.
Rename to a) gmp/ b) mpfr/ c) mpc/

3) A valid configure line :
../gcc-4.6.2/configure --prefix=/usr/local/gcc462 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++,fortran --disable-multilib --with-system-zlib --with-gmp-include=$(pwd)/gmp --with-gmp-lib=$(pwd)/gmp/.libs
( A hideaway location like /usr/local/gcc462/ is a must,
in order not to conflict with the system gcc, libgcc etc.)
Now you can do 'make' : There are no errors on Ubuntu 10.04, i686.

( Example "build gcc"
http://www.linuxquestions.org/questi...-5-1-a-842567/ )

/usr/local/gcc462/bin/gcc, /usr/local/gcc462/bin/g++ :
Suggest : Make symlinks to /usr/bin/ gcc462 g++462

.

hello,knudfl,thanks for your help, but i still can't success after following your advice.before I have install libppl0.10-dev libmpfr-dev gmp-4.3.2 mpfr-3.1.0 mpc-0.9.this is my command and error reported as follow:
Code:

stallone@stallone-desktop:~/build-gcc-all$ /usr/src/gcc/gcc-4.6.2/configure --prefix=/usr/local/gcc462 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++,fortran --disable-multilib --with-system-zlib --with-gmp=/usr/local/gmp --with-mpfr=/usr/src/mpfr --with-mpc=/usr/local/mpc --with-ppl=/usr/local/gmp --with-cloog=/usr/local  LDFLAGS="-L/usr/local/lib -Xlinker -R/usr/local/lib" CONFIG_SHELL=/bin/bash
stallone@stallone-desktop:~/build-gcc-all$make

Code:

gcc -c  -g -fkeep-inline-functions -DIN_GCC  -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H -I. -I. -I/usr/src/gcc/gcc-4.6.2/gcc -I/usr/src/gcc/gcc-4.6.2/gcc/. -I/usr/src/gcc/gcc-4.6.2/gcc/../include -I/usr/src/gcc/gcc-4.6.2/gcc/../libcpp/include -I/usr/local/gmp/include -I/usr/src/mpfr/include -I/usr/local/mpc/include  -I/usr/src/gcc/gcc-4.6.2/gcc/../libdecnumber -I/usr/src/gcc/gcc-4.6.2/gcc/../libdecnumber/bid -I../libdecnumber -I/usr/local/gmp/include  -I/usr/local/include  /usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c -o lto-compress.o
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:28:18: error: zlib.h: No such file or directory
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c: In function ‘lto_zalloc’:
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:60: error: ‘Z_NULL’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:60: error: (Each undeclared identifier is reported only once
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:60: error: for each function it appears in.)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c: In function ‘lto_zfree’:
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:69: error: ‘Z_NULL’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c: In function ‘lto_normalized_zlib_level’:
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:82: error: ‘Z_DEFAULT_COMPRESSION’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:84: error: ‘Z_NO_COMPRESSION’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:86: error: ‘Z_BEST_COMPRESSION’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c: In function ‘lto_end_compression’:
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:173: error: ‘z_stream’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:173: error: expected ‘;’ before ‘out_stream’
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:174: warning: ISO C90 forbids mixed declarations and code
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:179: error: ‘out_stream’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:185: error: ‘Z_NULL’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:187: warning: implicit declaration of function ‘deflateInit’
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:188: error: ‘Z_OK’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:189: warning: implicit declaration of function ‘zError’
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:189: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘int’
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:195: warning: implicit declaration of function ‘deflate’
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:195: error: ‘Z_FINISH’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:196: error: ‘Z_STREAM_END’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:197: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘int’
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:216: warning: implicit declaration of function ‘deflateEnd’
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:218: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘int’
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c: In function ‘lto_end_uncompression’:
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:265: error: ‘z_stream’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:265: error: expected ‘;’ before ‘in_stream’
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:266: warning: ISO C90 forbids mixed declarations and code
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:269: error: ‘in_stream’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:275: error: ‘Z_NULL’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:277: warning: implicit declaration of function ‘inflateInit’
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:278: error: ‘Z_OK’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:279: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘int’
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:285: warning: implicit declaration of function ‘inflate’
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:285: error: ‘Z_SYNC_FLUSH’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:286: error: ‘Z_STREAM_END’ undeclared (first use in this function)
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:287: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘int’
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:306: warning: implicit declaration of function ‘inflateEnd’
/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:308: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘int’
make[3]: *** [lto-compress.o] Error 1
make[3]: Leaving directory `/home/stallone/build-gcc-all/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/home/stallone/build-gcc-all'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/stallone/build-gcc-all'
make: *** [all] Error 2


John VV 02-17-2012 07:21 PM

most of us are concerned that seeing as you can not build the very new gcc 4.6.2 on an older 10.04
that you will NOT be able to hack the source code for most of the software you will build with 4.6.2

the gcc development team has been making EACH new version stricture than the last .Requiring software to NEED patching to build with the new compiler

or do you NEED that version ( ONLY) of gcc ,for some MUST USE very NEW software to be built on this older ubuntu

seeing as you are using the 10.04 LTS use the version of gcc BUILT FOR this operating system
that should be the gcc 4.3 or 4.4


the first line on your error
"error: zlib.h: No such file or directory"
you did NOT install the source/ headers for zlib
a basic part of the OS that should have been installed with
Code:

apt-get install build-essential
or
Code:

su -
apt-get install zlib-dev

but it might be "libz-dev"

KenJackson 02-17-2012 07:27 PM

Code:

/usr/src/gcc/gcc-4.6.2/gcc/lto-compress.c:28:18: error: zlib.h: No such file or directory
I find that the first error message is very often the most informative, even if there are hundreds to contend with.

On Fedora, zlib.h is in the zlib-devel package. It's probably something similar on Ubuntu.

knudfl 02-18-2012 01:57 AM

Quote:

--with-gmp=/usr/local/gmp --with-mpfr=/usr/src/mpfr --with-mpc=/usr/local/mpc \
--with-ppl=/usr/local/gmp --with-cloog=/usr/local LDFLAGS="-L/usr/local/lib \
-Xlinker -R/usr/local/lib" CONFIG_SHELL=/bin/bash
The above options can be omitted.
I am almost sure you will fail with those.
Please use an exact copy of the configure line in post # 8 ! ( edited.)
Nothing should be changed. Was written in that way for very good reasons.


Zlib issues : sudo apt-get install zlib1g-dev


Quote:

I have install .. .. gmp-4.3.2 mpfr-3.1.0 mpc-0.9
Those are not to be installed, just unpacked. See post #8, etc.
Better remove those from /usr/local/ :
Files in /usr/local/lib/ will conflict with system versions.
.

knudfl 02-18-2012 04:41 AM

And ... if you cannot build gcc-4.6.2 :
My result, gcc46-all-4.6.2.ubu1004_i386.deb, 26 MB, can be downloaded from
https://docs.google.com/open?id=0B7S...FhY2FjNTExNTRl

Provides /usr/local/gcc462/bin/ cpp gcc c++ g++ gfortran ..

.

Derek stallone 02-18-2012 11:34 AM

Quote:

Originally Posted by knudfl (Post 4605664)
The above options can be omitted.
I am almost sure you will fail with those.
Please use an exact copy of the configure line in post # 8 !
Nothing should be changed. Was written in that way for very good reasons.


Zlib issues : sudo apt-get install zlib1g-dev



Those are not to be installed, just unpacked. See post #8, etc.
Better remove those from /usr/local/ :
Files in /usr/local/lib/ will conflict with system versions.
.

Oh,knudfl,I understand your meaning,so stupid and careless I am!Thank you very much!
However,I indeed install the gmp ,mpfr and mpc in these directories,/usr/local/gmp ,/usr/src/mpfr ,/usr/local/mpc,respectively.
this is the respond from my pc after typing these command.
Code:

stallone@stallone-desktop:~/build-gcc-all$ ^C
stallone@stallone-desktop:~/build-gcc-all$ cd n..
bash: cd: n..: No such file or directory
stallone@stallone-desktop:~/build-gcc-all$ cd ..
stallone@stallone-desktop:~$ sudo rm -r build-gcc-all/
[sudo] password for stallone:
stallone@stallone-desktop:~$ mkdir build-gcc-all
stallone@stallone-desktop:~$ cd build-gcc-all/
stallone@stallone-desktop:~/build-gcc-all$ /usr/src/gcc/gcc-4.6.2/configure --prefix=/usr/local/gcc462 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++,fortran --disable-multilib --with-system-zlib
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
checking for the correct version of gmp.h... no
configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations.  Source code for these libraries can be found at
their respective hosting sites as well as at
ftp://gcc.gnu.org/pub/gcc/infrastructure/.  See also
http://gcc.gnu.org/install/prerequisites.html for additional info.  If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files.  They may be located in separate packages.


knudfl 02-18-2012 12:20 PM

Gcc will usually find gmp, mpfr, mpc ,,, when they are located
inside the gcc-<version>/ source.
Except gcc-4.6.2 : It didn't "find" mpfr.
( Hence 'sudo apt-get install libmpfr-dev' ).
Gcc did copy mpfr to the "build-folder" and compiled the libs,
Finished with that, the message "mpfr not found" appeared. EDIT : see post #8.

Please have a look into the build folder, and you will see
directories for the compiled gmp etc.
If gmp/ etc. is available from the gcc-<version>/ source.

*** Do not expect gcc to find the files in other locations.
Even if "configure --help" and the (old?) gcc documentation
tell how to point to libraries.
The GCC people recommend the LFS method for building gcc.
My configure line is like an "LFS configure line".

.


All times are GMT -5. The time now is 06:29 AM.