Cc command, linuxcc command

Source: Internet
Author: User

Cc command, linuxcc command

Most UNIX platforms call their C compilation programs through CC. In addition to the standard and CC, LINUX and FREEBSD also support gcc. The basic compilation Commands include the following:
1.-c
Compile and generate an object file (*. obj) instead of linking to an executable file, you can use this option when compiling several independent modules and linking them together by the linking program later, as shown in figure
$ Cc-c hello. c ==> hello. o $ cc hello. o
2.-o allows you to specify the output file name, for example, $ cc hello. c-o hello. o $ 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: one is to use-DMACRO, which is equivalent to using # define MACRO in the program, the other is to use-DMACRO = 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 compilation information is printed when the program is executed.
5. -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. out this command causes the include file and program 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.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.