LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 70
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
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Original Poster
Rep: Reputation: 70
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
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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: 55
"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: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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: 55
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: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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