The GNU Compiler Collection
or GCC
is a compiler and related auxiliary tools which are used to compile different programming languages into binary and related formats. GCC has been created and currently developed by the GNU Project. Also, the GCC name comes from the GNU as you have noticed. GCC is very popular in the opensource community and used by different projects like the Linux Kernel. GCC has played a very important role in the first two decades of the opensource movement by providing free, open-source, and dynamic compiler collection. GCC is provided with the GPL
or General Public License
where it permits the GCC to distributed in a free and opensource manner.
GCC History
GCC has been started by the GNU Project where Richard Stallman is its pioneer. GCC is first released in March 1987 from the MIT FTP servers. It is named as the first open-source and free software which is popularly used. First C Programming language was supported by in a year C++ programming language supported is added. Also later Objective-C, Objective-C++, Fortran, Java, Ada, and Go supported have been added. As writing this post the latest GCC version is 10.2 which has released July 2020.
GCC Supported Programming Languages
GCC is open source and flexible compiler collection where it supports a wide range of programming languages like below.
- C Programming Language
- C++ Programming Language
- Objective-C Programming Language
- Objective-C++ Programming Language
- Fortran Programming Language
- Ada Programming Language
- Go Programming Language
- Java Programming language
GCC Supported Hardware Platforms and Architectures
Like programming languages, GCC supported different hardware platforms and architectures like below.
- Alpha
- ARM
- IA-32
- IA-64
- MIPS
- PowerPC
- SPARC
- x86-64
- …
GCC Usage
GCC can be installed into different operating systems like Linux, Ubuntu, Fedora, CentOS, Debian, Mint, Kali, Windows, MacOS, etc. But the Linux platforms are the most comfortable platforms where GCC is mainly developed on Linux. GCC can be installed by using installers or package managers for the supported operating systems. GCC provides command-line usage where different options are provided in order to specify the compiling process details. Below you can find some basic usage examples about the GCC.
# Simply compile with GCC
$ gcc helloworld.c
# Compile into an executable file named hw
$ gcc helloworld.c -o hw
# Compile multiple files
$ gcc helloworld1.c myfile.c
# Show warning messages
$ gcc -Wall helloworld.c -o hw
Popular GCC Compiler Options
GCC is a features rich compiler toolset where different options are provided for different cases. GCC options are used to change the default compile attributes. For example extra input to the source code before compile can be provided with the macros etc. Below we will list some of the popular GCC compiler options below.
-c
option compiles source files into object files without linking.
-Dname=value
defines and provides preprocessor macro to the compilation process.
-fPIC
generates position independent code for shared libraries to be used by other binaries.
-glevel
generates debug information into binary which can be debugged for errors with gdb tool.
-llib
links given lib or library into the created binaries.
Ldir
look in given dir for library files to be used in compile process.
-o myexe
sets the created executable file as myexe.
-Olevel
optimize the code and creates optimized executables and binaries.
-shared
generates shared object file for shared library.
-w
disables all warning messages.
-Wall
enables all warning messages.
-Wextra
enables extra warning messages in a more verbose manner.