Say for instance a C program has been written and successfully compiled using a C compiler on a computer.If only the .exe file of this program is copied to another computer which doesn't have any C compiler installed on it then will it execute on that machine?I know a source program is compiled to generate the machine code(object code).This machine code is linked by the linker to the object modules to form the load module(.exe file) which is loaded into the memory by the loader for execution. That means the .exe file has the machine code present in it, but at the same time it's also true that the machine code depends on the instruction set, CPU config. of the specific computer.So will the .exe file execute on a different computer if the instruction sets are the same/if the instruction sets are different?(Assume both the computers are running on the same OS)
Asked
Active
Viewed 2,715 times
3
-
possible duplicate of [How can a program compiled to machine language run on different machines?](http://stackoverflow.com/questions/10521341/how-can-a-program-compiled-to-machine-language-run-on-different-machines) – Ken White Jul 11 '13 at 17:05
-
Also, I'd think you could figure this out with a little thought. Microsoft obviously doesn't provide the source code for all of Windows along with a c compiler on every computer, or the source code for MS Word or Excel with a c compiler. – Ken White Jul 11 '13 at 17:14
-
1You only need the compiler to create machine code from your source code. It is normally not needed afterwards (unless you rely on compilation within your application, but that is thought of as bad practice). The executable will run if it is compatible with the instruction set, with the operating system and with the installed libraries. Of course that does not say that the application may not generate other errors because it is missing resources (e.g. memory or a deliberate reliance on e.g. a file to be present). – Maarten Bodewes Jul 12 '13 at 13:43