A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/linux-unix/cc-command-in-linux-with-examples/ below:

cc command in Linux with Examples

cc command in Linux with Examples

Last Updated : 23 Sep, 2024

'cc' command 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

where,

Basic 'cc' Command Example

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

cc example.c
Important Options use with cc Command 1. cc command with -o option:

This command will compile the source_file.c file, and create an executable output file with the specified name.

cc example.c -o examp_out
2. 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
3. cc command with -w option:

This command will compile the 'source_file.c' file, but suppress all the warnings.

cc example.c -w 
4. cc command with -g option:

This command will compile the 'source_file.c' file, and create a dgging 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_debugebu
5. 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 
6. 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
7. 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 
8. 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
9. cc command with -v option:

This command will compile the 'source_file.c' file, and gives a verbose output.

cc example.c -v
Conclusion

The cc command is a powerful and flexible tool for compiling C programs in Linux. cc can help you optimize your builds, catch errors early, and generate debugging information when needed. By leveraging options like -Wall for warnings, -g for debugging, and -c for generating object files, you can ensure that your C programs are built efficiently and correctly.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4