'The output of GCC

I have GCC running on my Ubuntu operating system. I wrote a small program in C and tried compiling it. Its output was an a.out file like it would do on Windows. How can I make it put out a Linux executable?



Solution 1:[1]

Suppose your C file is f.c.

gcc f.c gives the a.out executable, and you can run it in a terminal as ./a.out.

gcc f.c -o myprog gives myprog as the executable, and you can run it in a terminal as ./myprog.

Solution 2:[2]

It is a Linux executable. a.out files (actual a.out format, not files named a.out by default) cannot be executed on Windows.

In both cases, most likely you get a standard executable usable in the local system, but named a.out. On Linux it's an ELF file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peter Mortensen
Solution 2 Peter Mortensen