Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have scenario in which
my host is : x86 32 bit processor
my target is : x86 64 bit processor

I have a couple of questions :

  • I want to know if i can simply compile a program in my host using the available gcc and run it on the target?
  • Do i need to cross compile it for x86 64 bit processor? If yes, how can i specify it while compiling?
  • Do i need to use separate tool-chain for cross-compiling the program?
share|improve this question
up vote 5 down vote accepted

All amd64 (i.e. 64-bit x64) processors can run 32-bit x86 binaries. Also, on most operating systems, you can run x86 programs on an amd64 OS. So it is often possible to deploy x86 binaries on amd64 processors.

Whether it's desirable to do so is a different matter. 64-bit OSes often come with a restricted set of 32-bit libraries, so if your program uses some uncommon libraries it will be easier to install a 64-bit executable. Depending on your application, there may or may not be a performance advantage to 32-bit or 64-bit binaries.

If you decide you want to deploy 64-bit executables, you'll need a cross-compililation environment for the amd64 (a.k.a. x86_64) architecture running on an x86 architecture. This means both a compiler, and static libraries to link against.

A gcc installation can share frontends and include multiple backends. But not many distributions ship with amd64 development tools on x86 platforms, so you may have to get your own (gcc is fairly straightforward to cross-compile). The same goes for libraries to link against (of course, once you have the compiler, you can recompile them from source).

As an example, Ubuntu 10.04 on x86 comes with a “multilib” version of gcc and an amd64 backend, plus a small set of 64-bit development packages (libc6-dev-amd64 Install libc6-dev-amd64 and depending and dependent packages).

share|improve this answer

yes you can: just specify the correct comnpiler options and you're done. You won't be able to run the resulting binary on your 32 bit host.

I think you need: CFLAGS=-m64 you'll also need to set LD_LIBRARY_PATH and similar to the 64-bit headers and libraries for your dependancies.

stackoverflow has a question with more answers.

share|improve this answer
ww.ubuntuforums.org/showthread.php?t=1377396.. Hope this link will help.. but havent tried yet.. Thanks, gbjbaanb.. :-) – Sen Dec 3 '10 at 13:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.