In-depth exploration of VC -- compiler cl.exe (1) http://blog.csdn.net/wangningyu/article/details/4830920

Source: Internet
Author: User

Cl.exe is used to compile source code files into OBJ object files that can be used by the linker. Cl.exe command line parameters are as follows:

CL (option ...) file... [Option | file]... [Lib...] [@ command-file] [/link-opt...]

 

The command line parameters have the following meanings:

1. Option

"Option" in the command line refers to one or more compilation options. When specifying an option, you must add a forward slash (/) or a short line (-) before the option (-). Some options also contain parameters, and ":" is used to specify the option parameters. For example, "/sybsystem: Windows, 5.0" is a compilation option, indicating that executable programs depend on Windows (Win32 graphical user interface application ), the minimum version is 5.0 (that is, Windows 2000 ). The option name is case sensitive (except for the/help option), and other options except the/link option are not required in order. All options specified during compilation will be applied to all source files specified by the user. Option command line parameters are optional.

 

2. File

The "file" in the command line is one or more source files to be compiled, either. OBJ or library files. Cl.exe compiles the source file and passes the. OBJ file and library name to the compiler. The file parameter is a required parameter of the compiler.

 

3. Lib

This option is used to specify one or more database names. Cl.exe directly transmits these names to the linker. Libis an optional parameter of cl.exe.

 

4. Command-File

It contains multiple options and file names. It is an optional parameter.

 

5. Link-OPT

One or more Linker Options. CL passes these options to the linker, which is also an optional parameter.

 

Example: Hello World:

 

[CPP]View plaincopyprint?

  1. // File name: Hello. c
  2. // Description: First Win32 Application
  3. // By Koma
  4. # Include <windows. h>
  5. # Pragma comment (Lib, "user32.lib ")
  6. Int winapi winmain (hinstance, hinstance hprevinstance, lpstr psz1_line, int cmdshow)
  7. {
  8. MessageBox (null, "Hello world! "," Test ", mb_ OK );
  9. Return 0;
  10. }

 

 

Compile the source file in the command line:

CL/O2/FA/GZ/FO hello. c

 

"Hello. C "the previous compilation options (that is, the option parameter)," Hello. C "is the source file (file parameter). It does not use command line parameters such as Lib, command-file, and link-OPT.

 

Before compiling a command line, you need to set your environment variables as follows:

 

Include C:/program files/Microsoft Visual Studio/vc98/include

Lib C:/program files/Microsoft Visual Studio/vc98/lib

Path C:/program files/Microsoft Visual Studio/common/msdev98/bin; C:/program files/Microsoft Visual Studio/vc98/bin

(If this is not the default setting, restart the computer after the setting is complete)

 

Now, we have learned about the compiler command line parameters ~~~

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.