2

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?

Gilles 'SO- stop being evil'
865k204 gold badges1.8k silver badges2.3k bronze badges
asked Apr 29, 2014 at 12:56
1
  • 1
    Filename a.out is the default output from C-compiler in GNU Compiler collection regardless of output format. Commented Apr 29, 2014 at 13:55

1 Answer 1

2

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.

answered Apr 29, 2014 at 13:03
2
  • 1
    And, 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 FreeBSD Commented 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. Commented Apr 29, 2014 at 23:16

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.