GCC COMAND
GCC
-----------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------
What is the meaning about GCC?:
GCC is abbreviated as GNU Complier Collection. GCC can compile C, C++, Ada and many more programming languages which are understandable by the system.
GCC is a short of GNU Compiler Collection, a C compiler for Linux.
---------------------------------------
Basic GCC Syntax:
gcc [options] [source_file] [object_files] [-o output_file]
- ----------------------------------------
- ----------------------------------------
Option:
- To check the default version of gcc compiler in your system, you can use the command as –version in your Linux command prompt.
- Compiles source files to object files without linking to any other object files.
- Includes the directories of header files
- link the code with the library files
- Build the output generated to output file
- Disables all warning messages during the compilation.
- enables all warning messages during the compilation
- Enables extra warning messages during the compilation.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
To Execute a C program, we need to follow three steps. They are:
- Write: C Program for which you want to compile in Linux environment.
- The basic syntax to compile a C code is: To compile a C Code, use the below syntax. This syntax is used without any options.
- When you compile the above code, you will get the output with the filename as a.out. The default output after compiling the C Program is resulted in”a.exe” or “a.out” format.
- We can also specify explicitly mention the output file name by using –o as an option.
- To see the warnings while we compile a C program: we need to use an option –wall while compiling the C Program as below:
- To get preprocessed output with –E option: the output will be produced on stdout to redirect our result in other file. Here output.i would contain the preprocessed result.
- To get intermediate files using –save-temps: We can store all the intermediate files that are generated during the compilation in the same directory from where we do the compilation.
- To see the error while compiling the C Program: To see the error during the compilation of C Program, we can use the option –W. This is one of the best practices to use to avoid errors.
- To debug C Program in Linux: To debug C Program in Linux during compilation can be done by using –ggdb.
- Verbose option is to see the complete description used in Linux during the compilation. The command –v is used as below:
- The final step is to run the C program in Linux OS by using the below syntax:
- https://www.geeksforgeeks.org/gcc-command-in-linux-with-examples/
- https://web.mit.edu/rhel-doc/3/rhel-gcc-en-3/invoking-gcc.html
- https://www.rapidtables.com/code/linux/gcc.html
--------------------------------------------------------------------------------------------------------------------------------
REFERENCIAS:
geeksforgeeks https://www.geeksforgeeks.org/gcc-command-in-linux-with-examples/
rapidtables.com https://www.rapidtables.com/code/linux/gcc.html
educba.com https://www.educba.com/gcc-command-in-linux/
Comentarios
Publicar un comentario