Most UNIX platforms call their C compilation programs through CC. in addition to the standard and CC, Linux and FreeBSD also support GCC. there are several basic compilation commands: 1. -C compilation generates object files (*. OBJ) instead of linking to executable files, you can use this option when compiling several independent modules and linking them together by the linking program later, such: $ CC-C hello. c ==> hello. o $ CC hello. O 2. -o allows you to specify the output file name, such as $ CC hello. c-O hello. O or $ CC hello. c-o Hello 3. -G indicates that the compilation program should generate debugging information in the compilation output. this debugging information allows source code and variable names to be referenced in the debugging program or used to analyze the core file when the program exits unexpectedly. 4. -D allows you to define macro symbols from the compile program command line in two cases: Use-dmacro, equivalent to use # define macro in the program, and use-dmacr O = A, which is equivalent to # define macro. for example, the following code: # ifdefine debug printf ("Debug message/N"); # The-ddebug parameter can be added during endif compilation, and the execution program prints the compilation information. -I can specify other locations for searching include files. for example, if some include files are located in special places, such as/usr/local/include, you can add the following options: $ CC-c-I/usr/local/include-I/opt/include hello. c. The directory search will be performed in the given order. 6. -E is relatively standard. It allows you to modify the command line so that the compiler sends the pre-processed C file to the standard output without actually compiling the code. this is useful when viewing C pre-processing pseudo commands and C macros. possible compilation outputs can be redirected to a file again, and then analyzed using the editing program: $ CC-c-e hello. c> CPP. O Ut this command causes the include files and programs to be pre-processed and redirected to the file CPP. out. later, you can use the editing program or paging command to analyze the file and determine what the final C language code looks like. 7. -O optimization options, this option is not the standard-O and-O1 Specify level 1 Optimization-O2 Specify level 2 Optimization-O3 Specify level 3 Optimization-O0 specify not to optimize $ CC-C O3-O0 hello. c. When multiple optimizations occur, the last one prevails !! 8.-wall uses the GNU Compiler at the highest level and is used to display warnings !! $ Gcc-wall hello. c 9. -L specifies the search directory for the connected database, and-l (lower case l) specifies the name of the connected database $ GCC main. the commands above O-L/usr/lib-lqt-O hello put the target file main. O is connected to the library QT. the/usr/lib file will be searched for during the connection. in other words,-l and-l are usually paired.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service