C program compiling in Linux system:

The method of compiling C language in Linux

Option Description:

-Wall means that the compiler will output warning messages during the compilation process, such as some variables that you did not use, wrong type of pointer, main function did not return integer value, etc.

Although this kind of information is not an error and does not affect the compilation, it is likely to be the source of program bugs. It also helps you to find errors in the code and standardize the code format. So it is recommended to add the – wall parameter every time you compile.

-G means that the compiler will collect debugging information, so that if your program runs wrong, you can debug it line by line by GDB or lldb to find out the cause of the error. If you are not 100% sure that your program is OK, it is recommended to add the – g parameter. It’s a lot easier to debug.

-O means that the compiler will output the compiled executable file with the name you specify to the folder you specify- O is the name of the output file.

For example: – O is followed by test, which means that GCC will generate an executable file called test in my current directory after successful compilation. If you do not add this parameter, the executable file generated after each compilation will be placed in the root directory, called a.out. Every time the compilation is successful, the previous a.out file will be overwritten. So it is suggested to add the – O parameter to make it more organized.

The above is the details of how to compile c language in Linux.

Leave a Reply

Your email address will not be published. Required fields are marked *