LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   .bin, .elf, .out - Linux file extension (https://www.linuxquestions.org/questions/linux-software-2/bin-elf-out-linux-file-extension-755062/)

raedbenz 09-14-2009 07:22 AM

.bin, .elf, .out - Linux file extension
 
Hi,,

I have been reading the web and i found that they say the equivalent of .exe in linux is either .elf or .bin, is that true?

how do i get a file with .bin or .elf extension? cause AFAIK when compiling using gcc we get a.out.
thanks

knudfl 09-14-2009 07:36 AM

Linux and other *nix don't use / need extensions.
Have a look in e.g. /usr/bin/ or do 'ls /usr/bin/'
.....

You only get a.out with no name specified.

' -o myobject ' will create 'myobject'
.....

raedbenz 09-14-2009 07:51 AM

Hi,,

And what about getting a file extension .bin?
i have seen some executables with .bin extension, how do we get that?

knudfl 09-14-2009 08:08 AM

1) Files ending with ' .bin ' are most often binary installers.
And you are not getting a name. The name is decided by you, if
you are creating the file.

2) Most files can be renamed to any name and still be recognized
as their particular file type. The command 'file' can be used or
you can ask "Properties" to tell by right clicking the file.
In the desktop manager KDE : hoover the mouse cursor over the
file and get the type.
.....
Another example : 'photo.jpg' can be renamed to 'my-photo'
and still be opened by your favorite image viewer. No extension !
.....

archlinux_jessica 09-14-2009 08:43 AM

Explination
 
To explain it from my understanding, its like this.

You state that when you compile a program using gcc you get a lot of a.out files. This is because you didn't specify a name. Using gcc --help or man gcc you can learn each different compiler option. To make a name you do this.

gcc -o MyProgram MySource.c

That takes your program that is called MySource.c and creates a file called MyProgram. Unlike windows the . extension is meaningless. A .bin file simply means a binary file. Which in the case I showed above MyProgram IS a binary file. So if you need to have a .bin extension you could do this.

gcc -o Prog.bin MySource.c

And there you go. Though Prog.bin and MyProgram are the same file with a different name.

-Jessica-

tredegar 09-14-2009 01:58 PM

Quote:

And what about getting a file extension .bin?
i have seen some executables with .bin extension, how do we get that?
You just rename executable to executable.bin
The extension is irrelevant to linux.
Test it out:
Code:

tred@vaio:~$ file image.jpg
image.jpg: JPEG image data, JFIF standard 1.01
tred@vaio:~$ cp image.jpg image
tred@vaio:~$ file image
image.jpg: JPEG image data, JFIF standard 1.01
tred@vaio:~$

The file image will still open with the default application associated with the filetype JPG, even though it lacks the .jpg extension.

(Linux is usually more sensible than win.)

lutusp 09-14-2009 06:00 PM

Quote:

Originally Posted by raedbenz (Post 3682157)
Hi,,

I have been reading the web and i found that they say the equivalent of .exe in linux is either .elf or .bin, is that true?

No, it isn't. There are any number of files that are executable, and not because of their extension. Unices have an executable flag that is part of the information stored about a file, and that flag determines whether the file is executable.

In Windows, by contrast, a file's extension is important because the Windows file system is too primitive to include the concept of an executable flag.

Quote:

Originally Posted by raedbenz (Post 3682157)
how do i get a file with .bin or .elf extension? cause AFAIK when compiling using gcc we get a.out.
thanks

Use the "-o" option to choose a file name and extension:

$ gcc source.file -o output.file

It is up to you to decide whether the extension you choose is appropriate to the circumstances.

chrism01 09-15-2009 12:34 AM

ELF is a (*nix) binary format: http://en.wikipedia.org/wiki/Executa...inkable_Format, not an extension.
As said above, xxx.bin is (usually) a self-extracting installer.
HTH


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