LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 11-12-2008, 08:17 AM   #1
prerp
LQ Newbie
 
Registered: Jun 2008
Location: china
Posts: 7

Rep: Reputation: 0
Red face Why a windows programe(*.exe) can't run in a Linux system?


em~ maybe it's a foolish problem

a programe's file is made of what? machine code?
 
Old 11-12-2008, 08:29 AM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
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.
 
Old 11-12-2008, 08:32 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
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.
 
Old 11-12-2008, 09:31 AM   #4
Duck2006
Member
 
Registered: Sep 2006
Distribution: Ubuntu 8.04 Hardy Heron LST
Posts: 346

Rep: Reputation: 33
http://linux.oneandoneis2.org/LNW.htm
 
Old 11-12-2008, 09:39 AM   #5
prerp
LQ Newbie
 
Registered: Jun 2008
Location: china
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pixellany View Post
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 ~~~ %*&%*&^%*
 
Old 11-12-2008, 10:41 AM   #6
ronlau9
Senior Member
 
Registered: Dec 2007
Location: In front of my LINUX OR MAC BOX
Distribution: Mandriva 2009 X86_64 suse 11.3 X86_64 Centos X86_64 Debian X86_64 Linux MInt 86_64 OS X
Posts: 2,369

Rep: Reputation: Disabled
Quote:
Originally Posted by prerp View Post
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 ~~~ %*&%*&^%*
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.

Last edited by ronlau9; 11-12-2008 at 10:42 AM. Reason: save too soon
 
Old 11-13-2008, 11:57 PM   #7
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by prerp View Post
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.
 
Old 11-14-2008, 12:07 AM   #8
ashik.rock
LQ Newbie
 
Registered: Nov 2008
Posts: 3

Rep: Reputation: 0
hello

windows is .exe filesystem

linux .rpm file system
 
Old 11-14-2008, 12:28 AM   #9
billymayday
Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Quote:
Originally Posted by prerp View Post
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 ~~~ %*&%*&^%*
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.
 
Old 11-14-2008, 12:31 AM   #10
AceofSpades19
Senior Member
 
Registered: Feb 2007
Location: Chilliwack,BC.Canada
Distribution: Slackware64 -current
Posts: 2,079

Rep: Reputation: 57
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
 
Old 11-14-2008, 12:34 AM   #11
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
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.
 
Old 11-14-2008, 12:44 AM   #12
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
Quote:
Originally Posted by prerp View Post
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.

Last edited by pinniped; 11-14-2008 at 12:46 AM.
 
Old 11-14-2008, 01:04 AM   #13
SqdnGuns
Member
 
Registered: Aug 2005
Location: Fountain Valley, CA / Thailand
Distribution: Slackware64 14.0
Posts: 981

Rep: Reputation: 88
Quote:
Originally Posted by ashik.rock View Post
hello

windows is .exe filesystem

linux .rpm file system
W T F...........put the pipe down.
 
Old 11-14-2008, 05:32 AM   #14
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 3,517

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
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.
 
Old 11-14-2008, 10:39 AM   #15
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
Post

Quote:
Originally Posted by prerp View Post
em~ maybe it's a foolish problem
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 View Post
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 View Post
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.

Last edited by ErV; 11-14-2008 at 10:48 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
run windows exe file in Linux? shipon_97 Linux - Newbie 5 11-24-2008 10:42 PM
how to run .exe file as we run the samwe in windows chandrala13 Linux - Newbie 2 05-22-2008 06:30 AM
How to run windows based .exe programs on linux slsscoot Linux - Newbie 7 04-20-2008 06:28 PM
run windows exe munna_dude Programming 4 10-10-2007 04:29 PM


All times are GMT -5. The time now is 10:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration