LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-31-2011, 10:40 AM   #1
nova49
Member
 
Registered: Nov 2010
Distribution: Slackware
Posts: 74

Rep: Reputation: 0
executable files


I have been doing some work with assembly and low level stuff like that and had some questions. When programs are compiled they are converted into machine language. The problem is that all of the books I read assumes the user uses Linux.

How come windows .exe files can not be run in Linux? I under stand there are some proprietary software that might be required like directx but I'm not talking about that. How come the same C program compiled in a Linux environment and a windows environment cant be interchanged? What is physically different about compiling a program in windows and Linux? Is one way better then the other or are they just different ways to reach the same place? I haven't done any work with apple computers but I assume that its similar to Linux.

I have been looking around the internet and the best answer I have been able to get so far is "because that's how it is" and "because windows uses file extensions". If somebody were able to give me the facts or point me to a website that does I would be very happy.
 
Old 03-31-2011, 10:48 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
This is a reasonable (though still rather vague) summary which is consistent with what I think the reason is... Essentially, Linux executables need to use a different set of OS calls to get input/output and system utilities such as memory allocation to Windows executables. Also, I think the way DLLs and Linux libraries work may well be different
 
Old 03-31-2011, 10:53 AM   #3
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Your initial understanding of how executable files work is incomplete.

If an executable file ran alone in memory then it would have to include all of the code to read the keyboard and draw on the screen. That used to be the case. Then operating systems were invented. Operating systems were very simple in the beginning. Then more capabilities were added over time.

Now when you compile a program your code does not have to include all of the machine instructions to read the keyboard and draw on the screen. However different operating systems implement common features in different ways. Also different operating systems each have some unique features.

The way that a compiled program uses the features of an operating system is by making calls to application program interface (API) functions. These are implemented differently on different operating systems so when a Windows program draws a dot on the screen it accomplishes this by calling the Windows API for this. When an UNIX program wants to draw a dot on the screen it does this by calling the UNIX API for this. These API calls are not compatible from one operating system to another.

That is why a Windows program cannot run directly on UNIX or Linux or other operating systems and vice versa.

Edit: Geez Snark. You weren't even reading this thread when I started writing.

Last edited by stress_junkie; 03-31-2011 at 01:18 PM.
 
1 members found this post helpful.
Old 03-31-2011, 11:08 AM   #4
nova49
Member
 
Registered: Nov 2010
Distribution: Slackware
Posts: 74

Original Poster
Rep: Reputation: 0
That makes sense.

Thanks for the very quick response.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Execution of non-executable files ? Meson Linux - General 5 06-26-2008 03:11 AM
Executable files @er<> Linux - Newbie 2 03-10-2007 06:35 PM
executable files prophetk Linux - Software 2 06-25-2006 08:39 AM
Converting perl files to executable mac files mrozkan Programming 0 04-16-2002 09:56 AM
Executable Files Acar Linux - General 1 02-22-2002 10:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:50 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
Open Source Consulting | Domain Registration