GCC
GCC
The GCC is an open-source C-Compiler. It is the de-facto compiler standard and integral part of Linux.
The basic usage of the gcc from the command line is:
gcc <source file 1> <source_file 2> ...
This will compile all given C source files and link with the standard library to produce an executable.
Among the diversity of gcc options the most notable options are:
- -o <file>
specify name of output file (usually object file or executable) - -c
just compile object code, don’t link - -Wall
print all warnings to identify all potential problems- -Wno-parentheses
do not print a warning about omitted braces for single statements
- -Wno-parentheses
- -g
generate object code that is suitable for debugging with the gdb - -O
optimize object code- -O1 -O2 -O3
levels of code optimization. higher level means faster code but longer compile time
- -O1 -O2 -O3
- -I<path>
additional path to search include files, except the predefined ones and the actual directory - -l<archive>
link with archive, the archive name expands to libname.a - -L<path>
additional path to search archive files (libraries), except the predefined ones (actual directory is not included by default) - -std=c99: specify Iso C99 standard compliance (will be the standard for future gcc versions)
The same options apply for the C++ compiler, the GNU g++ compiler, as well.