LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Compiling newer version of gcc separately (https://www.linuxquestions.org/questions/linux-general-1/compiling-newer-version-of-gcc-separately-937276/)

mvairavan 03-30-2012 09:33 AM

Compiling newer version of gcc separately
 
Hi,
I want to compile a new version gcc but i dont want to upgrade the previous version. I want to have both the version available on my system. I understand that compiling gcc is the only way, since there wont be any binaries for gcc available. Am i right?

I have started compiling it anyway, and i have some doubts (rather many!).

The way which i am doing now is have 3 dirs

srcdir - For all the extracted source codes
objdir - Where i actually configure an do a make
sysroot - Where i install, using prefix option

So the order is,

1. gmp
2. mpfr with the new gmp
3. mpc with the new gmp,mpfr

After this i get a good looking bin,lib,share folders in my sysroot.

4. binutils with the new gmp,mpfr,mpc

But after this step i get more folders lib64,x86-64-unknown-linux. What is this x86-64-unknown-linux? why does it have a bin and a lib again?

Is these steps correct?

And my question is will this use all my older system header files? should i install a new linux kernel header files as well, so that it is perfectly updated?

5. gcc - with the new gmp,mpfr,mpc,ld,as,sys-root

This is throwing me an error stating system include files is not present in the sysroot/usr/include

So what am i doing wrong here, or what have i missed here.

Thanks in advance.

mvairavan 03-30-2012 09:46 AM

In the last step (5th step) without --sys-root option it says

configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[2]: *** [configure-stage1-target-libgcc] Error 1

knudfl 03-30-2012 12:54 PM

Might be simpler than you imagine.
First : Usually more than one compiler is available in your 'Package Manager',
and can be installed. Which Linux OS are you using ? ?

All gcc versions 3.2.3 .. 4.7 can be compiled. And: gcc uses no kernel files.

Example 4.5, post #2 here
http://www.linuxquestions.org/questi...-1-a-842567/#2

4.6 , post #8 here
http://www.linuxquestions.org/questi...hine-929660/#8

No gmp, mpfr, mpc needs to be installed, as you can see from the examples.
"x86-64-unknown-linux" : No OS was specified.
.

mvairavan 03-30-2012 01:45 PM

Quote:

Originally Posted by knudfl (Post 4640843)
Might be simpler than you imagine.
First : Usually more than one compiler is available in your 'Package Manager',
and can be installed. Which Linux OS are you using ? ?

All gcc versions 3.2.3 .. 4.7 can be compiled. And: gcc uses no kernel files.

Example 4.5, post #2 here
http://www.linuxquestions.org/questi...-1-a-842567/#2

4.6 , post #8 here
http://www.linuxquestions.org/questi...hine-929660/#8

No gmp, mpfr, mpc needs to be installed, as you can see from the examples.
"x86-64-unknown-linux" : No OS was specified.
.

Thanks for your reply. Its really good to know that i am some what in correct direction.

I am running Fedora 14, i am trying to build gcc-4.7

I tried putting mpc, mpfr, gmp (the latest versions) inside the gcc folder but it dint work out for me, that is why i went to this option.

So i need to have the following pre-requisites:
1.mpc
2.mpfr
3.gmp
4.gcc-g++
5.binutils-devel
6.glibc-devel
7.elfutils-libelf-devel

I have the first 3 but for the next 4, i cannot do a yum install. I have to transfer it to this machine and do it.
So i have to download rpm's of it and install it manually.

But could you please guide me for the location where i have to install these packages? can i put them under gcc source directory will it be built by itself?

And if can provide download locations it will be so helpful. If u cannot never mind, i will find it.

knudfl 03-30-2012 01:53 PM

OK, gcc-4.7 : An example here
http://nosemaj.org/debian-gcc-4-7

Ref. http://www.linuxquestions.org/questi...eeze-936581/#3

mvairavan 03-30-2012 02:07 PM

Quote:

Originally Posted by knudfl (Post 4640886)

So i dont need to build glibc-devel or binutils-devel??
Will that work?? Anyways trying it out now..
But if the glibc is not updated will my gcc be up to date?

mvairavan 03-30-2012 03:17 PM

I followed the example link you mentioned, Everything worked fine until the make of gcc.

It throws me this error message -

/usr/lib/../lib/crti.o: could not read symbols: File in wrong format
collect2: error: ld returned 1 exit status


this crti.o is a symlink to the one in /usr/lib64/crti.o

John VV 03-30-2012 04:18 PM

fedora 14 is PAST it's END OF LIFE
there currently is NO support and there will NEVER be any support


install fedora 17 ( testing ONLY alpha/beta)

fedora 17 will have gcc 4.7 BY DEFAULT

or wait a few weeks for the official fedora 17 release

mvairavan 03-30-2012 10:29 PM

Quote:

Originally Posted by John VV (Post 4640974)
fedora 14 is PAST it's END OF LIFE
there currently is NO support and there will NEVER be any support


install fedora 17 ( testing ONLY alpha/beta)

fedora 17 will have gcc 4.7 BY DEFAULT

or wait a few weeks for the official fedora 17 release

OS is not a problem now, i am pretty much satisfied with what i have got now.
Even if i update to Fedora17, then in few months there would be an updated version of gcc which i would be needing. So i really need to figure out the way to compile different versions of gcc's.

John VV 03-30-2012 11:42 PM

there is almost NO reason to update gcc past 4.3
MOST software will not even build in gcc 4.6 let alone 4.7

i ROUTINELY have to drop from gcc 4.5 to 4.3 or 4.1
and even sometimes 3.4

mvairavan 03-31-2012 12:31 AM

Quote:

Originally Posted by John VV (Post 4641138)
there is almost NO reason to update gcc past 4.3
MOST software will not even build in gcc 4.6 let alone 4.7

i ROUTINELY have to drop from gcc 4.5 to 4.3 or 4.1
and even sometimes 3.4

I doing it on a system which has gcc 4.1 surprisingly. I would be even happy to compile 4.5 or even 4.3 as you said (though it seems to be an answer just for today). But my prob here is not with version, its about compiling gcc. If i can do one version properly then i would do as many as i want.

Quote:

/usr/lib/../lib/crti.o: could not read symbols: File in wrong format
collect2: error: ld returned 1 exit status

this crti.o is a symlink to the one in /usr/lib64/crti.o

Since it was just a symlink, i deleted it and tried make. Now it shows


/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib64/libc.so when searching for -lc
/usr/bin/ld: cannot find -lc
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status

Guys please help me out, i am stuck with this for two full days now.. :banghead:

John VV 03-31-2012 01:35 AM

you could backport the src.rpm from fedora 17 back to 14
from koji
http://koji.fedoraproject.org/koji/p...o?packageID=40
4.7.0
http://koji.fedoraproject.org/koji/b...buildID=308850


also you might want to have a look over at the
" End Of Life" section on fedoraforum
http://forums.fedoraforum.org/forumdisplay.php?f=75

and have a read ( it is old so you will NEED to update it )
and have a look at the links at the bottom of the page
http://www.mjmwired.net/resources/mjm-fedora-gcc.html

this is for building an older version of gcc on fedora 15
-- it is close --
http://dummdida.blogspot.com/2011/10...fedora-15.html



you WILL WANT to use "--program-suffix=-4.7.0 " in your configure line so you do not kill what is installed

then set up "alternatives " so you can move from 4.1 to 4.7


as to the error
you have installed the FULL development tools ? right ?
for a listing
Code:

su -
yum grouplist

there should be a development tools & development libraries
Code:

su -
yum groupinstall "Development Tools" "Development Libraries"

also for gcc
Code:

su -
yum install glibc-devel.i686 glibc-devel.x86_64  gmp-devel mpfr-devel


mvairavan 03-31-2012 02:29 AM

Quote:

Originally Posted by John VV (Post 4641178)
you could backport the src.rpm from fedora 17 back to 14
from koji
http://koji.fedoraproject.org/koji/p...o?packageID=40
4.7.0
http://koji.fedoraproject.org/koji/b...buildID=308850


also you might want to have a look over at the
" End Of Life" section on fedoraforum
http://forums.fedoraforum.org/forumdisplay.php?f=75

and have a read ( it is old so you will NEED to update it )
and have a look at the links at the bottom of the page
http://www.mjmwired.net/resources/mjm-fedora-gcc.html

this is for building an older version of gcc on fedora 15
-- it is close --
http://dummdida.blogspot.com/2011/10...fedora-15.html



you WILL WANT to use "--program-suffix=-4.7.0 " in your configure line so you do not kill what is installed

then set up "alternatives " so you can move from 4.1 to 4.7


as to the error
you have installed the FULL development tools ? right ?
for a listing
Code:

su -
yum grouplist

there should be a development tools & development libraries
Code:

su -
yum groupinstall "Development Tools" "Development Libraries"

also for gcc
Code:

su -
yum install glibc-devel.i686 glibc-devel.x86_64  gmp-devel mpfr-devel


Hi as i have said in the previous posts i cannot do a yum install. I have to install it manually.

No i dont have development packages or libraries installed. I was following this link.. http://nosemaj.org/debian-gcc-4-7

So how do i install glibc-devel and other development tools and libraries.
I have gmp,mpfr,mpc,ppl,cloog installed into a separate directory.
So i prefer installing all the other libraries needed also be installed into this directory.

John VV 03-31-2012 03:54 AM

the fedora 14 repos are still there - nothing will be added, and in time they will disappear . But they are still up

you still can use "yum"

unless this fedora 14 box has no internet connection
and if you do not have a internet connection on that box -- it is going to be VERY hard to install anything

and WHY are you fallowing a DEBIAN tutorial for Fedora ???
that is like using a GM manual to fix your FORD car - it dose NOT work

though that link is fairly generic, except that fedora dose NOT use /usr/local
so you will need to install the REQUIRED development software

mvairavan 03-31-2012 05:13 AM

Quote:

Originally Posted by John VV (Post 4641255)
the fedora 14 repos are still there - nothing will be added, and in time they will disappear . But they are still up

you still can use "yum"

unless this fedora 14 box has no internet connection
and if you do not have a internet connection on that box -- it is going to be VERY hard to install anything

and WHY are you fallowing a DEBIAN tutorial for Fedora ???
that is like using a GM manual to fix your FORD car - it dose NOT work

though that link is fairly generic, except that fedora dose NOT use /usr/local
so you will need to install the REQUIRED development software

I was following that tutorial because it simple and generic. I cannot do yum install because of no internet connection and i dont want to add any extra packages in the main system folders of that machine. I want this gcc to installed completely separately.


All times are GMT -5. The time now is 04:21 PM.