This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Compiling GCC for different machine on same Architecture
- From: Paul Smith <paul at mad-scientist dot net>
- To: Jaya Pavan Bhattiprolu <pavanbhattiprolu at gmail dot com>
- Cc: Andrew Haley <aph at redhat dot com>, gcc-help at gcc dot gnu dot org
- Date: Tue, 02 Sep 2014 12:45:09 -0400
- Subject: Re: Compiling GCC for different machine on same Architecture
- Authentication-results: sourceware.org; auth=none
- References: <CAABpWqfjO6pHBhBLzJTTE0L-SM30fqYwAQdOy61wAkqK9joDvw at mail dot gmail dot com> <5405E1B7 dot 1060001 at redhat dot com> <CAABpWqfd=AYMphEczj3zyBAwxORfKqw2eTM_pzKedPkr7ph6UA at mail dot gmail dot com>
> On Tue, Sep 2, 2014 at 8:56 PM, Andrew Haley <aph@redhat.com> wrote:
> > On 09/02/2014 04:07 PM, Jaya Pavan Bhattiprolu wrote:
> >> Can Anyone provide solution or how to achieve this task.
> >
> > Install CentOS 7 in a virtual machine. Anything else will only
> > and in tears.
On Tue, 2014-09-02 at 21:48 +0530, Jaya Pavan Bhattiprolu wrote:
> You mean its not achievable or its a difficult?
I didn't see the original question (missed it somehow) but it's pretty
straightforward to build software for "other" distributions using modern
versions of GCC... depending on how many dependencies the software has.
For basic system library requirements for a Red Hat system, for example,
you just need to get a copy of the base and "devel" RPMs for each of
those libraries from the release you want to target, unpack them into a
separate directory, then add the --sysroot flag to your invocation of
GCC pointing at that directory.
So for example if you get the glibc, glibc-common, glibc-devel,
glibc-headers, libgcc, and kernel-headers packages from RHEL5 then
unpack them into a directory like "/home/sysrooots/rhel5" (I use cpio
with the --no-absolute-filenames option to unpack the RPM) you'll get
stuff like:
/home/sysroots/rhel5/usr/include/...
/home/sysroots/rhel5/usr/lib/...
/home/sysroots/rhel5/lib/...
etc.
Then run "gcc --sysroot /home/sysroot/rhel5 ..." for both compilation
AND linking.
Obviously if your software needs more libraries you'll have to add more
RPMs, and the farther up the "stack" you go, away from the base system
libraries, the more complex and less portable things become.