The Wayback Machine - https://web.archive.org/web/20230512155130/https://www.geeksforgeeks.org/cc-command-in-linux-with-examples/
Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

cc command in Linux with Examples

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

cc command is stands for C Compiler, usually an alias command to gcc or clang. As the name suggests, executing the cc command will usually call the gcc on Linux systems. It is used to compile the C language codes and create executables. The number of options available for the cc command is very high. The most important options are explained below with examples.

Syntax:

cc [options] files

Example: Below command will compile the source_file.c file, and create the default executable output file, a.out.

cc example.c

Important Options:

  • cc command with -o option: This command will compile the source_file.c file, and create a executable output file with the specified name.
    cc example.c -o examp_out

  • cc command with -Wall option: This command will compile the source_file.c file, and check for all errors and warnings in the program.
    cc example.c -Wall -o examp_out

  • cc command with -w option: This command will compile the source_file.c file, but suppress all the warnings.
    cc example.c -w 

  • cc command with -g option: This command will compile the source_file.c file, and create a debugging version of the executable output file. This output file can be used by the debugger, and is usually much larger in size than the normal output files.
    cc example.c -g -o examp_out_debug

  • cc command with -c option: This command will compile the source_file.c file, and create an object file source_file.o, which can later be linked to create an executable output file.
    cc example.c -c 

  • cc command with -Ldir option: This command, while compiling the source_file.c file, will also search the specified directory for header files.
    cc example.c -L /home/mukkesh/Desktop

  • cc command with -ansi option: This command will compile the source_file.c file, and makes sure that the code follows strict ANSI standards. This will make sure that the code is portable to be compiled on any other system.
    cc -ansi example.c 

  • cc command with –dump options: These commands specified below will print the version of the cc command, the default target machine and built-in specification strings.
    cc -dumpversion

    cc -dumpmachine

    cc -dumpspecs

  • cc command with -v option: This command will compile the source_file.c file, and gives a verbose output.
    cc example.c -v

My Personal Notes arrow_drop_up
Last Updated : 15 May, 2019
Like Article
Save Article
Similar Reads
Related Tutorials