Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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
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.
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
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511
Rep:
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.
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.
/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:
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
Last edited by Derek stallone; 02-17-2012 at 06:19 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
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.
.
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.
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511
Rep:
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".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.