LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-27-2008, 09:27 AM   #1
trist007
Member
 
Registered: May 2008
Distribution: Slackware
Posts: 991

Rep: Reputation: 56
I have a question about binary executables


I've been starting to use gcc in fedora 8 to compile and run programs in C. I have a dual boot system going with fedora 8 and win xp. My question is, since I compile the src code into an executable binary file (a.out) in fedora 8 using gcc, and since both OS are obviously running the same cpu architecture x86, theoretically, this a.out executable binary file should run in winxp, right? I don't need a cross compiler if the program is in binary machine code that my processor can understand. Is my understanding correct?

How would I go about running a.out in winxp? Is there some command in cmd?
 
Old 06-27-2008, 10:35 AM   #2
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
Loading The Image

I believe this has to do with the linker and the instructions necessary to get your executable image loaded into memory and run. There is wine to go from Windows to Linux, and perhaps with the right libraries you might be able to run this under cygwin, but I've never tried it. I would conditionally compile the source for either OS.
 
Old 06-27-2008, 11:05 AM   #3
trist007
Member
 
Registered: May 2008
Distribution: Slackware
Posts: 991

Original Poster
Rep: Reputation: 56
I thought that since a.out is broken down into machine code(binary), that it isn't necessary to load libraries since the source code is already interpreted into machine language. Theoretically, it should work by simply loading into memory.
 
Old 06-27-2008, 11:11 AM   #4
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
No it won't work. Not only are the system calls different, an elf file is different than a windows executable.
 
Old 06-27-2008, 11:11 AM   #5
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 54
"a.out" is AFAIK a really old format - todays standard is "ELF"
No - a binary (or a library) compiled to run on linux is not going to run on windows.
Wether a.out or ELF - makes no difference there.

Last edited by jomen; 06-27-2008 at 11:12 AM.
 
Old 06-27-2008, 12:06 PM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,953

Rep: Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603
jomen : a.out is just the object, you are getting from gcc,
when no object name is specified, still an ELF file.
I think, I read that it was changed in gcc-4.3 (released 18 days ago ?).

Rgds

Last edited by knudfl; 06-27-2008 at 12:09 PM.
 
Old 06-27-2008, 01:42 PM   #7
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 54
Though I run Gentoo I don't know much of this except that I remember now that you are saying this - you are right.
But then again - isn't this just the name?

I guess I'm confused by the text I quite often read when configuring a new kernel:

Section: Executable file formats
[*] Kernel support for ELF binaries
< > Kernel support for a.out and ECOFF binaries
<*> Kernel support for MISC binaries

the help-texts on the second:
Quote:
A.out (Assembler.OUTput) is a set of formats for libraries and
executables used in the earliest versions of UNIX. Linux used
the a.out formats QMAGIC and ZMAGIC until they were replaced
with the ELF format.

The conversion to ELF started in 1995. This option is primarily
provided for historical interest and for the benefit of those
who need to run binaries from that era.

Most people should answer N here. If you think you may have
occasional use for this format, enable module support above
and answer M here to compile this support as a module called
binfmt_aout.
 
Old 06-28-2008, 01:29 AM   #8
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,953

Rep: Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603Reputation: 2603
Seems to be more than one explanation, googling a.out,
most say "old" and...
http://www.ncsa.uiuc.edu/UserInfo/Re...iles/a.out.htm

Rgds
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about Binary search on mips. cyborgt Programming 3 02-21-2008 05:41 PM
Encrypting scripts into Binary Executables muazfarooqaslam Linux - Newbie 6 01-08-2008 07:01 AM
LXer: To binary or not to binary, that is the question LXer Syndicated Linux News 0 12-31-2006 09:33 AM
FreeBSD - Binary packages question vharishankar *BSD 1 08-10-2006 11:57 AM
Question about Executables fotwoca Linux - Newbie 5 01-24-2002 05:54 PM


All times are GMT -5. The time now is 10:40 PM.

Main Menu
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