Compile 32bit or 64bit

T.C. Hollingsworth tchollingsworth at gmail.com
Fri Dec 16 09:06:10 UTC 2011


On Fri, Dec 16, 2011 at 1:51 AM, Mahdi Foladgar <foladgar at gmail.com> wrote:
> Hi
> I have two computer installed FC16 on them. On the First FC16x86-64
> installed and on the other FC16-i386 installed.
> Can I compile some program on one and run on the other?
> I want to compile my program on 64 bit os and run on 32bit os or vice versa.

Programs compiled 32-bit will run just fine on 64-bit operating
systems, so long as you have all the necessary 32-bit libraries.
However, 64-bit binaries will not work on 32-bit systems.  You can
also compile 32-bit applications on 64-bit systems and vice versa, but
you need a cross compiler setup which can be a PITA.

Personally, I also like to keep as much managed by RPM as possible.
So, if I want a custom version of a package provided by Fedora, I just
modify it's RPM specfile, and for projects that don't exist I create
my own RPMs.  When you use RPM, you can build 32-bit and 64-bit
versions regardless of the architecture of the system you happen to be
using at the time very easily, using mock.  Compiling a 32-bit RPM on
a 64-bit system is as easy as:
% mock -r fedora-16-i386 --rebuild super-cool-app-0.1.fc16.src.rpm

For more information on creating your own RPMs, see:
http://fedoraproject.org/wiki/How_to_create_an_RPM_package

For more information on mock, see:
http://fedoraproject.org/wiki/Projects/Mock

-T.C.


More information about the users mailing list