Why a windows programe(*.exe) can't run in a Linux system?
em~ maybe it's a foolish problem:eek:
a programe's file is made of what? machine code? |
Well, simply put, Linux is not Windows and Windows isn't Linux. Different filesystems, different libraries, etc.
In order to run Windows programs within Linux, you need a program like WINE or CodeWeavers. But you're usually better off just finding a native Linux equivalent to the program you're trying to run. |
Anything that is "executable" has to be in machine code---ie it must contain the CPU instruction codes. A high-level program (AKA "application") has to have all the right interfaces into the operating system, and typically uses a variety of standard libraries. The interfaces and libraries on Windows and Linux are very different.
You might want to look at WINE or Crossover for running Winodows .exe files in Linux. |
|
Quote:
Assume there a a programe that have only "machine code" and without any system's call.(do it exist?) can that programe run on both system? for example: Move x1, x2 Move x2, x1 Move x1, x2 Move x2, x1 programe "must contain the CPU instruction codes". why can a programe run on different computer(different cpu) within the same operation system. I am a :newbie:~~~ %*&%*&^%* |
Quote:
We have two types the OS and Applications. The OS is on the software side the BIG BOSS. The applications runs under the OS . So the applications could not be more power full than the OS is As example commands in applications as OPEN and CLOSE MOVE and so on what it really does depends on the OS and not on the computer platform. |
Quote:
In C, your code might look like Code:
a = b; In assembly (which is processor dependent), it might be Code:
mov a, b (destination first argument, source second argument) Code:
mov b, a (source first argument, destination second argument) Code:
move b, a (source first argument, destination second argument, instruction different) When you compile the c-code on a X86 machine, the compiler will generate the correct machine (binary) code for the x86; it's however very unlikely that that machine code will work on the sparc processor. You need to compile the c-code again on the machine with the sparc processor to get the correct machine code for it (or use a cross-compiler). When you're using assembly, it's clear that code written for one processor will not necessarily work on another one as the mov instruction has a different syntax (so it will copy a to b or b to a) or the instruction itself is different. There's nothing that you can do about it except for rewriting the code. I hope that I did not confuse the issue more. |
hello
windows is .exe filesystem linux .rpm file system |
Quote:
You really wouldn't want either system to give unprotected execution ability on either system would you in this day and age of various types of malware (some here would say Windows in admin mode already does). When you say programs run on different cpus, that's only really true where they are instruction set compatible or backwards compatible. As said previously, a totally different CPU requires a different binary that has been compiled for it. |
A windows program won't run in linux because it has different binary files, Linux uses elf files and windows uses PE files. Also windows programs can't use the windows api in linux because it doesn't exist except if you have wine or its derivatives
|
Sure a program has machine code in it. That's only part of the story. Programs also have tables in them indicating what other programs (libraries) they may need to use and the functions to use in those libraries. The tables also have the addresses of functions, including main() which is the one called when a program is started.
Now *one* problem with winduhs *.exe files in Linux is that these tables are not arranged the same and information is not quite represented in the same way, so Linux doesn't know how to start the *.exe. A second problem is that winduhs and Linux communicate with programs in a different way. The operating system essentially provides access to hardware, and *all* software must interact with it. One typical way of getting this done is to put information in certain CPU registers and then generate a software interrupt. Some operating systems use multiple interrupts but if I recall correctly, Linux only uses one. It just happens that winduhs and Linux use different registers and different interrupts - so even if you wrote another program to place that *.exe into memory and begin execution, the program will still not run because it can't communicate with the kernel. This is where WINE comes in - it will load a program, 'link' it as appropriate with libraries, and intercept system calls intended for winduhs while providing a substitute equivalent to the winduhs system call. For a better explanation of linux system calls see: http://www.ibm.com/developerworks/li...lls/index.html Now for CPUs - different families of CPUs have different instruction sets, so you *cannot* run a program on different CPUs simply because the operating system has the same name. Linux is written in a "high-level" language, C, and can be compiled for many CPU families. Although the more abstract code (C) is mostly the same, the final executable code is very different. This is why you cannot install Linux for x86 on an ARM computer. |
Quote:
If you remove the operating system, then you can write executable code and run it as you please - which is useful sometimes, but for most modern machines that people use for computing it is far more convenient to have an operating system. The x86 processor family, thanks to history, will first run a BIOS. That BIOS can load a piece of code (usually the bootloader) and execute it. A boot loader runs *before* the operating system is loaded (the operating system takes control of the computer and usually the BIOS becomes useless or even inaccessible after that). Now the same bootloader (lets say 'lilo') can happily exist on a system with Linux only or a system with winduhs only and it will boot that system. So a bootloader functions almost as you describe - except that there is no operating system at this point in time, so you cannot say the bootloader is running under one system or the other. [edit] Part of the BIOS itself, of course, is machine code. |
Quote:
|
Quote:
However, operating systems have many complex tasks to perform and any useful program requires manipulation of hardware e.g screen, keyboard, disk drive, memory. It is the differences in how operating systems handle these tasks that make it impracticable to run Windows .exe in Linux without the use of special software such as Wine. |
Quote:
Quote:
However it is possible to write library that'll work on both systems (as long as CPU architectures and endianness will be compatible) if there is loader for it. For your information - mplayer can use *.dll files for codecs (windows "libraries), even on Linux. Please note that library is not what people normally call a program, it is collection of functions. Quote:
|
All times are GMT -5. The time now is 02:29 PM. |