This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Compiling GCC for different machine on same Architecture


> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]