🌐
Linux Man Pages
man7.org › linux › man-pages › man1 › gcc.1.html
gcc(1) - Linux manual page
gcc [-c|-S|-E] [-std=standard] [-g] [-pg] [-Olevel] [-Wwarn...] [-Wpedantic] [-Idir...] [-Ldir...] [-Dmacro[=defn]...] [-Umacro] [-foption...] [-mmachine-option...] [-o outfile] [@file] infile... Only the most useful options are listed here; see below for the remainder.
🌐
Linux Man Pages
linux.die.net › man › 1 › gcc
gcc(1): GNU project C/C++ compiler - Linux man page
( NOTE: This manual does not describe the Objective-C and Objective-C ++ languages themselves. See · This section describes the command-line options that are only meaningful for Objective-C and Objective-C ++ programs, but you can also use most of the language-independent GNU compiler options. For example, you might compile a file "some_class.m" like this: gcc -g -fgnu-runtime -O -c some_class.mIn this example, -fgnu-runtime is an option meant only for Objective-C and Objective-C ++ programs; you can use the other options with any language supported by GCC .
🌐
Oracle
docs.oracle.com › cd › E86824_01 › html › E54763 › gcc-1.html
gcc - man pages section 1: User Commands
Most of the command-line options that you can use with GCC are useful for C programs; when an option is only useful with another language (usually C++), the explanation says so explicitly. If the description for a particular option does not mention a source language, you can use that option with all supported languages. The gcc program accepts options and file names as operands. Many ...
🌐
GNU
gcc.gnu.org › onlinedocs › gcc › Invoking-GCC.html
Invoking GCC (Using the GNU Compiler Collection (GCC))
When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The “overall options” allow you to stop this process at an intermediate stage. For example, the -c option says not to run the linker. Then the output consists of object files output by the assembler.
🌐
GNU
gcc.gnu.org › onlinedocs › gcc › Option-Summary.html
Option Summary (Using the GNU Compiler Collection (GCC))
-fcall-saved-reg -fcall-used-reg -ffixed-reg -fexceptions -fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables -fasynchronous-unwind-tables -fno-gnu-unique -finhibit-size-directive -fcommon -fno-ident -fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt -fno-jump-tables -fno-bit-tests -frecord-gcc-switches -freg-struct-return -fshort-enums -fshort-wchar -fverbose-asm -fpack-struct[=n] -fleading-underscore -ftls-model=model -fstack-reuse=reuse_level -ftrampolines -ftrampoline-impl=[stack|heap] -ftrapv -fwrapv -fwrapv-pointer -fvisibility=[default|internal|hidden|protected] -fstrict-volatile-bitfields -fsync-libcalls -fzero-init-padding-bits=value -Qy -Qn
🌐
Arch Linux Man Pages
man.archlinux.org › man › gcc.1.en
gcc(1) — Arch manual pages
Print (on the standard output) a description of the command-line options understood by gcc. If the -v option is also specified then --help is also passed on to the various processes invoked by gcc, so that they can display the command-line options they accept.
🌐
GNU
gcc.gnu.org › onlinedocs › gcc
Top (Using the GNU Compiler Collection (GCC))
You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. 1 Programming Languages Supported by GCC · 2 Language Standards Supported by GCC · 3 GCC Command Options ·
🌐
GNU
gcc.gnu.org › onlinedocs › gcc › Overall-Options.html
Overall Options (Using the GNU Compiler Collection (GCC))
% gcc -Q -mabi=2 --help=target -c The following options are target specific: -mabi= 2 -mabort-on-noreturn [disabled] -mapcs [disabled] The output is sensitive to the effects of previous command-line options, so for example it is possible to find out which optimizations are enabled at -O2 by using:
🌐
Shorttutorials
shorttutorials.com › apt-get-commands › man-gcc.html
man gcc Command | Man Page for gcc in Linux
This manual documents only one of these two forms, whichever one is not the default. OPTIONS Option Summary Here is a summary of all the options, grouped by type. Explanations are in the following sections. Overall Options c S E o file combine pipe pass exit codes x language v · < Previous : Remove ImapsyncNext : Install Inkscape > How do you remove imapsync in Linux / UNIX using apt-get command?
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › gcc-command-in-linux-with-examples
gcc command in Linux with examples - GeeksforGeeks
November 21, 2021 - It can also be used to compile Objective C and Objective C++. The most important option required while compiling a source code file is the name of the source program, rest every argument is optional like a warning, debugging, linking libraries, object file etc. The different options of gcc command allow the user to stop the compilation process at different stages.
Top answer
1 of 2
3

Your question

What gcc -o sample sample.c actually does

The command you have pasted triggers gcc to compile sample.c. As a result you'll get an output/executable with the same sample.

The parameters (as -o in your example which defined the name of the output file ) are explained in the man page of gcc. You can open it by running man gcc

I am quoting the -o section of the man page here

-o file

       Place output in file file.  This applies to whatever sort of output
       is being produced, whether it be an executable file, an object
       file, an assembler file or preprocessed C code.

       If -o is not specified, the default is to put an executable file in
       a.out, the object file for source.suffix in source.o, its assembler
       file in source.s, a precompiled header file in source.suffix.gch,
       and all preprocessed C source on standard output.

In General

Wikipedia explains a good amount of gcc here.

I am quoting only the start - but the complete article is worth a read and offers a lot of additional links and references

The GNU Compiler Collection (GCC) is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain. The Free Software Foundation (FSF) distributes GCC under the GNU General Public License (GNU GPL). GCC has played an important role in the growth of free software, as both a tool and an example.

Originally named the GNU C Compiler, when it only handled the C programming language, GCC 1.0 was released in 1987. It was extended to compile C++ in December of that year. Front ends were later developed for Objective-C, Objective-C++, Fortran, Java, Ada, and Go among others.

GCC has been ported to a wide variety of processor architectures, and is widely deployed as a tool in the development of both free and proprietary software. GCC is also available for most embedded platforms,[citation needed] including Symbian (called gcce), AMCC, and Freescale Power Architecture-based chips. The compiler can target a wide variety of platforms, including video game consoles such as the PlayStation 2 and Dreamcast.

As well as being the official compiler of the GNU operating system, GCC has been adopted as the standard compiler by many other modern Unix-like computer operating systems, including Linux and the BSD family, although FreeBSD and OS X have moved to the LLVM system. Versions are also available for Microsoft Windows and other operating systems; GCC can compile code for Android and iOS.

2 of 2
1

GCC is GNU C (language) compiler. It's used to "convert" programs written in C programming language into binary executable on computer.

The syntax gcc -o sample sample.c means: Compile the file sample.c and name the output sample.

Then you can launch your compiled program with <path_to_file>/sample, or from within the directory ./sample

The default name for compiled program is a.out, so with -o parameter you can specify your desired output name.

🌐
GNU
gcc.gnu.org › onlinedocs
GCC online documentation - GNU Project
GNU M2 15.2 Manual (also in PDF or PostScript or an HTML tarball) GCC COBOL 15.2 Manual Page (also in PDF) and GCC COBOL 15.2 I/O API Manual Page (also in PDF)
🌐
Unix.com
unix.com › unix for beginners q & a › unix for dummies questions & answers
man gcc - UNIX for Dummies Questions & Answers - Unix Linux Community
January 14, 2002 - Hi all, How can I get man page to recognize gcc when i need to look up gcc options? I tried "man gcc" but got a response "no manual entry for gcc". Thanks a bunch, Rachael
🌐
Linux Command Library
linuxcommandlibrary.com › man › gcc
gcc man | Linux Command Library
Specifies the C or C++ standard to use (e.g., -std=c99, -std=c++11). -v Prints the commands executed by the compiler driver and the compiler's version. gcc (GNU Compiler Collection) is a highly optimized and widely used compiler system developed by the GNU Project.
🌐
GNU
gcc.gnu.org › onlinedocs › gcc.pdf pdf
Using the GNU Compiler Collection For gcc version 16.0.1 (pre-release) (GCC)
You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU devel- ... Programming Languages Supported by GCC . . . . . . . . . . . . . . . 1 ... Language Standards Supported by GCC . . . . . . . . . . . . . . . . . . . 3 ... GCC Command Options.
🌐
Ticalc
tigcc.ticalc.org › doc › comopts.html
GCC Command-Line Options
This part of the documentation is a modified version of the Command-Line Options section of the GCC Manual. Therefore it is licensed under the GNU Free Documentation License. This section describes the options supported by gcc, the driver program of the GNU Compiler Collection, whose C compiler ...
🌐
Ubuntu
manpages.ubuntu.com › manpages › trusty › man1 › gcc.1.html
Ubuntu Manpage: gcc - GNU project C and C++ compiler
If the -v option is also specified then --help is also passed on to the various processes invoked by gcc, so that they can display the command-line options they accept. If the -Wextra option has also been specified (prior to the --help option), then command-line options that have no documentation associated with them are also displayed.
🌐
Medium
david4tech.medium.com › how-to-use-the-gcc-command-in-linux-f253162ab37f
How to use the GCC command in Linux | by David Arias Fuentes | Medium
June 11, 2020 - The “overall options” allow you to stop this process at an intermediate stage. Then the output consists of object files output by the assembler. To read more about all the possible options with this command you can just type: man gcc gcc --help ...