LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Why a windows programe(*.exe) can't run in a Linux system? (https://www.linuxquestions.org/questions/linux-general-1/why-a-windows-programe-%2A-exe-cant-run-in-a-linux-system-682870/)

prerp 11-12-2008 07:17 AM

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?

trickykid 11-12-2008 07:29 AM

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.

pixellany 11-12-2008 07:32 AM

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.

Duck2006 11-12-2008 08:31 AM

http://linux.oneandoneis2.org/LNW.htm

prerp 11-12-2008 08:39 AM

Quote:

Originally Posted by pixellany (Post 3339412)
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.

windows and linux have different interfaces.......
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:~~~ %*&%*&^%*

ronlau9 11-12-2008 09:41 AM

Quote:

Originally Posted by prerp (Post 3339488)
windows and linux have different interfaces.......
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:~~~ %*&%*&^%*

If we looks to software side of a computer.
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.

Wim Sturkenboom 11-13-2008 10:57 PM

Quote:

Originally Posted by prerp (Post 3339488)
programe "must contain the CPU instruction codes". why can a programe run on different computer(different cpu) within the same operation system.

It does NOT. Below a simplified explanation

In C, your code might look like
Code:

a = b;
which copies the content of variable b to variable a
In assembly (which is processor dependent), it might be
Code:

mov a, b      (destination first argument, source second argument)
or
Code:

mov b, a      (source first argument, destination second argument)
or even
Code:

move b, a    (source first argument, destination second argument, instruction different)
In machine code (binary), the mov(e) instruction for each processor might be different again (e.g. for a sparc processor it might be 0x0003 and for an x86 it might be 0x2233)

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.

ashik.rock 11-13-2008 11:07 PM

hello

windows is .exe filesystem

linux .rpm file system

billymayday 11-13-2008 11:28 PM

Quote:

Originally Posted by prerp (Post 3339488)
windows and linux have different interfaces.......
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:~~~ %*&%*&^%*

Theoretically what you are talking about may be possible. I say may, because you would need to run such a program with elevated privileges, since the OS provides a certain level of abstraction (and takes a certain element of control) over the physical hardware.

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.

AceofSpades19 11-13-2008 11:31 PM

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

pinniped 11-13-2008 11:34 PM

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.

pinniped 11-13-2008 11:44 PM

Quote:

Originally Posted by prerp (Post 3339488)
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?

*no* Linux, for example, uses the latest ELF specification for the program and the information needed for the operating system to actually invoke the code. winduhs has their own executable format. To run code such as you describe, you need to write specialized code to load and execute it under Linux and under winduhs - and what is the point of that?

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.

SqdnGuns 11-14-2008 12:04 AM

Quote:

Originally Posted by ashik.rock (Post 3341422)
hello

windows is .exe filesystem

linux .rpm file system

W T F...........put the pipe down.

allend 11-14-2008 04:32 AM

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?
Yes, it can. Think of a Windows DLL file. This is a collection of position independent machine language routines that are called using defined parameters. The same routines can be used in Linux if the appropriate calls are made. Wine makes heavy use of this.
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.

ErV 11-14-2008 09:39 AM

Quote:

Originally Posted by prerp (Post 3339399)
em~ maybe it's a foolish problem:eek:

Because of different file format, because of different sets of libraries used by program, and because OS are very different. So use either WINE or any kind of virtual machine.

Quote:

Originally Posted by prerp (Post 3339488)
windows and linux have different interfaces.......
Assume there a a programe that have only "machine code" and without any system's call.(do it exist?)

I can not imagine such program, because (as I remember it) to finish program you might have to use system call. And system calls are also used on startup.
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:

Originally Posted by ashik.rock (Post 3341422)
hello

windows is .exe filesystem

linux .rpm file system

There is no such thing as ".exe filesystem" and there is no such thing as ".rpm filesystem". If you aren't experienced enough, please, stay away from giving incorrect/misleading information to other people.


All times are GMT -5. The time now is 02:29 PM.