I'm a bit confused. I just read this: http://www.es.freebsd.org/doc/handbook/binary-formats.html, which basically says that freeBSD uses the elf binary format. But when I compile my code I using cc, I get a file called a.out.
So what's going on here? Can I somehow specify in which format cc should build my code? Does freeBSD just support both formats? Is the resulting executable actually in elf format, but is it just called a.out for some reason:P?
1 Answer 1
The a.out
file is still leftover from when compilers were using the a.out format. If you check the file with file a.out
you will see it is actually in ELF format.
To specify the name of the output file, use cc -o exec_name code.c
.
-
1And, you could double-check it using the "file" command; Example inside Linux:
file /usr/bin/file: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, stripped
. You should have a simmilar output of this command on FreeBSDuser34720– user347202014年04月29日 13:07:04 +00:00Commented Apr 29, 2014 at 13:07 -
I'd say it the other way round — the a.out format was named that way because
a.out
was the default output file name for the assembler. The default file name remained but the format name stuck to the classical file format.Gilles 'SO- stop being evil'– Gilles 'SO- stop being evil'2014年04月29日 23:16:29 +00:00Commented Apr 29, 2014 at 23:16
a.out
is the default output from C-compiler in GNU Compiler collection regardless of output format.