Question

I always had these questions in my mind before I start learning C++:

1- Could an application that is compiled on a x86 computer run on a x64 computer?

2- Could an application that is compiled on a x64 computer run on a x86 computer?

3- Is there any difference?

4- If 1 and 2 are yes, Then why some applications have different downloads for each os bits, and why some libs I got like lua52 has a x64 and x86 version which work on the specified os only and errors on different os?

EDIT:

5- Can I compile my applications in x86 if my os is x64?

Was it helpful?

Solution

Ok, let's try and address those points in turn

  1. Yes, an x86 computer could cross compile to x64 code (this is a common practice). Also the x64 based operating system may have an emulation layer for running x86 code (This is what Windows does for backwards compatibility)

  2. Yes, a x64 computer could cross compile to x86 code (also a common practice). In theory, a x86 based operating system could have an emulation layer for running x64 code (though I don't believe this is done in practice)

  3. In the case of cross compilation, there'll be no difference between a x64 code compiled on an x64 computer vs the same code cross compiled on a x86 computer. If the x64 is running an emulation layer to run x86 code, then it'll be less efficient than running native x64 code. If you want to support x86 systems, then you'll have to provide an x86 version.

  4. See (3) - It's generally better better to provide 'native' versions.

  5. Yes. - see (1) and (2)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top