Detailed explanation of cl.exe parameters

Taken from Baidu


 The problem of precompiled header is finally solved. 2011.2.11 The new year started
CL.exe link.exe command (transfer)


1. Set environment variables:

PATH=C:\Program Files\Microsoft Visual Studio 8\VC\bin

INCLUDE=C:\Program Files\Microsoft Visual Studio 8\VC\include

LIB=C:\Program Files\Microsoft Visual Studio 8\VC\lib

If you are prompted that the mspdb80.dll file cannot be found, copy the four files "msobj80.dll, mspdb80.dll, mspdbcore.dll, mspdbsrv.exe" from C:\Program Files\Microsoft Visual Studio 8\Common7\IDE to C:\Program Files\Microsoft Visual Studio 8\VC\bin.

 

2. Command options:

1) /C: keep comment statements in preprocessed output

2) /c: Only compile, not link, which is equivalent to selecting "Compile" under the "Build" menu

3) /D: Define constants and macros, which have the same effect as #define in the source program

4) /E: Preprocess C, C++ source files, expand all precompiled instructions and macros in the source files, remove comments, and then copy the output of the preprocessor to the standard output device output, and in each file Add #line at the beginning and end

5) /EH: Specifies which exception handling model the compiler uses

6) /EP: same as /E, just remove the #line

7) /F: Set the stack size of the program

8) /FA: Set what kind of list files are generated (assembly, assembly and machine code, assembly and source code, assembly and machine code, and source code)

9) /Fa: Specify the storage path and/or file name of the list file set with /FA

10) /FD: Interdependence information of generated files

11) /Fd: Set the storage path and/or file name of the program database file (PDB)

12) /Fe: Set the storage path and/or file name of the final executable file

13) /FI: Preprocess the specified header file, which has the same effect as #include in the source file

14) /Fm: Create map file

15) /Fo: Set the storage path and/or file name of the compiled Obj file

16) /Fp: Set the storage path and/or file name of the precompiled file (pch)

17) /FR: Generate browsing information (sbr) file

18) /Fr: same as /FR, except that /Fr does not include local variable information

19) /G3: Optimize code generation for 80386 processors

20) /G4: Optimize code generation for 80486 processors

21) /G5: Optimize code generation for Pentium processors

22) /G6: Optimize code generation for Pentium Pro processors

23) /GA: Optimized for Windows applications

24) /GB: Optimize code generation for Pentium processor, use the mixed instruction set of 80386, 80486, Pentium, and Pentium Pro, which is the default option for code generation (Processor corresponds to Blend in the program properties option)

25) /GD: Optimize for Windows dynamic library (dll), this switch is not implemented in VC6

26) /Gd: Specify function call rules using __cdecl

27) /Ge: activate stack detection

28) /GF: Eliminate the duplicate string in the program and put it into a read-only buffer

29) /Gf: Eliminate duplicate strings in program

30) /Gh: call hook function at the beginning of each function --penter

31) /Gi: allow incremental compilation

32) /Gm: Allow minimal rebuild

33) /GR: Allow Run-Time Type Information (Run-Time Type Information)

34) /Gr: Specify function calling rules using __fastcall

35) /Gs: control the memory size used for stack detection

36) /GT: support fier-safety for data allocated with __declspec(thread)

37) /GX: allow synchronous exception handling, equivalent to the /EHsc switch

38) /Gy: allows the compiler to encapsulate each function in the form of COMDATs for the linker to call

39) /GZ: Allow to catch Release build errors during Debug build

40) /Gz: Specify the function call rule using __stdcall

41) /H: limit the length of external names

42) /HELP: List all command switches of the compiler

43) /I: Specifies the search path for header files

44) /J: Change the default type of char from signed char to unsigned char

45) /LD: create a dynamic link library

46) /LDd: Create a Debug version of the dynamic link library

47) /link: Pass the specified options to the linker

48) /MD: select the multithreaded, DLL version of the C Run-Time library

49) /MDd: select multithreading, DLL, Debug version of C Run-Time library

50) /ML: select single-threaded version of C Run-Time library

51) /MLd: select the single-threaded, debug version of the C Run-Time library

52) /MT: select the multithreaded version of the C Run-Time library

53) /MTd: Select the multi-threaded, Debug version of the C Run-Time library

54) /nologo: do not display the copyright information of the program

55) /O1: optimize to produce minimal executable code

56) /O2: optimize to produce the fastest executable code

57) /Oa: Instructs the compiler that no aliases are used in the program, which can improve the execution speed of the program

58) /Ob: Control expansion of inline functions

59) /Od: disable code optimization

60) /Og: use global optimization

61) /Oi: Use internal functions to replace function calls in the program, which can make the program run faster, but the length of the program becomes longer

62) /Op: Improve the consistency of floating-point comparison operations

63) /Os: generate the smallest executable code possible

64) /Ot: Generate executable code as chunky as possible

65) /Ow: Instruct the compiler not to use aliases inside the function body

66) /Ox: Combines several optimization switches to achieve as many optimizations as possible

67) /Oy: Prevent the creation of frame pointers in the call stack

68) /Q1f: Generate separate debug information for kernel-level device drivers

69) /QI0f: fix Pentium 0x0f error command

70) /Qifdiv: fix Pentium FDIV error command

71) /P: Write the preprocessing output to the specified file, the suffix of the file is I

72) /TC: Compile all files on the command line as C source programs, regardless of whether the suffix is ​​.c

73) /Tc: Compile the specified file as a C source program, regardless of whether the suffix is ​​.c

74) /TP: Compile all files on the command line as C++ source programs, regardless of whether the suffix is ​​.cpp

75) /Tp: Compile the specified file as a C++ source program, regardless of whether the suffix is ​​.cpp

76) /U: remove a specified previously defined symbol or constant

77) /u: remove all previously defined symbols or constants

78) /V: embed version number in compiled obj file

79) /vd: disable/allow constructor substitution

80) /vmb: Select the representation of the pointer, use this switch, before declaring a pointer to a member of a class, the class must be defined

81) /vmg: Select the representation method of the pointer, use this switch, before declaring a pointer to a member of a class, it is not necessary to define the class first, but first specify which inheritance method this class uses

82) /vmm: Set the pointer representation to Single Inheritance and Multiple Inheritance

83) /vms: Set the pointer representation to Single Inheritance

84) /vmv: Set the representation of the pointer to Any class

85) /W: Set the warning level

86) /w: suppress all warnings

87) /X: prevent the compiler from searching the standard include directories

88) /Yc: create precompiled header file (pch)

89) /Yd: write full debug info in all obj files

90) /Yu: use the specified precompiled header file during the build process

91) /YX: Instruct the compiler to use the precompiled header file if it exists, and create a precompiled header if it does not exist

92) /Z7: Generate MSC7.0 compatible debugging information

93) /Za: Disable language extensions (Microsoft Extensions to C)

94) /Zd: debug information only includes external and global symbol information and line number information

95) /Ze: Allow language extensions (Microsoft Extensions to C)

96) /Zg: Generate a function prototype for each function defined in the source file

97) /ZI: Generate program library files (Pdb) and support Edit and Continue debugging features

98) /Zi: Generate a program library file (pdb), including type information and symbolic debugging information

99) /ZL: remove default library filename from obj file

100) /Zm: set compiler memory allocation xianzhi

101) /Zn: disable browsing of packages in info files

102) /Zp: Set the encapsulation format of structure members in memory

103) /Zs: Quick check for syntax errors

--------------------------

File types supported by vc

1) DSW: The full name is Developer Studio Workspace, the highest-level configuration file, which records the configuration information of the entire workspace. She is a plain text file that is automatically generated when vc creates a new project

2) DSP: The full name is Developer Studio Project, which is also a configuration file, but it records all the configuration information of a project, a plain text file

3) OPT: A configuration file used in conjunction with DSW and DSP. It records information related to machine hardware. The content of opt files for the same project on different machines is different.

4) CLW: Records information related to ClassWizard. If the clw file is lost, there is no class information in the Class View panel.

5) PLG: It is actually a hypertext file that can be opened with Internet Explorer, records the build process, and is a log file

6) RC: Resource description file, which records all resource information, the modifications made in the resource editor are actually modifications to the RC file

7) RC2: Additional resource description files, which cannot be modified directly by the resource editor, but can only be added manually, which can be used to add additional resources

8) RES: The resource file compiled by the resource editor is stored in binary mode

9) SBR: The browser information file generated by the compiler is very useful when navigating the code. She needs to specify the /FR or /Fr switch at compile time

10) BSC: BSCMAKE.EXE takes all SBR files as input, and outputs a BSC file after processing. The BSC file is actually used during code navigation

11) ILK: When the incremental compilation link is selected, the linker automatically generates an ILK file and records the link information

12) PDB: The full name is Program DataBase, that is, the program database file, which is used to record debugging information. It is a very important file. Without it, the program cannot be debugged normally.

13) LIB: If the project output is Dll, it will generally output a Lib file with the same name as the project, and record the output function information

14) EXP: Same as Lib, it is the output file generated with Dll

15) PCH: The full name is PreCompiled Header, which is a pre-compiled header file, which is automatically generated by the compiler when the /Yu switch is specified at compile time

 


2008-11-14 17:15

CL.exe is a 32-bit tool that controls the Microsoft C and C++ compilers and linkers. The compiler produces Common Object File Format (COFF) object (.obj) files. The linker produces executable files (.exe) or dynamic link library files (DLLs).
  
Note that all compiler options are case-sensitive.
  
To compile but not link, use /c.
  
Use NMAKE to generate output files.
  
Class browsing is supported using BSCMAKE.
  
Below is a complete categorized list of compiler options.
  
Optimization
  
Options    Action
/O1 Create small code   
/O2 Create fast code   
/Oa Assume no aliasing   
/Ob Control inline expansion   
/Od Disable optimizations   
/Og Use global optimizations   
/Oi Generate intrinsics   
/Op Improve floating point consistency   
/Os Code size first   
/Ot code speed first   
/Ow assume aliasing in function calls   
/Ox use maximum optimization (/Ob1gity /Gs)   
/Oy omit frame pointer   
  
code generation
  
Option    What it does
/clr Enable managed extensions for C++ and produce output files that run on the common language runtime   
/EH Specifies the exception handling model   
/G3 optimizes code to prefer the 386 processor. Deprecated in Visual C++ 5.0, the compiler will ignore this option   
/G4 to optimize code in favor of the 486 processor. Deprecated in Visual C++ 5.0, the compiler will ignore this option   
/G5 Optimize code in favor of Pentium   
/GB and /G6 equivalent; set the value of _M_IX86 to 600    /Gd activate stack probing   
using __cdecl calling convention    /Ge /GF /GF enable string pooling    /GH call hook function _penter    /GH call hook function _pexit    /GL enable whole program optimization    /Gm enable minimum regeneration    /Gr enable runtime type information (RTTI)    /Gr use __fastcall call Conventions    /GS control stack probing    /GT support for fiber safety of data allocated using static thread local storage    /GX enable synchronous exception handling    /Gy enable function-level linking   













/GZ Use the __stdcall calling convention   
/MD Use MSVCRT.lib to create a multithreaded DLL   
/MDd Use MSVCRTD.lib to create a debug multithreaded DLL   
/ML Use LIBC.lib to create a single-threaded executable   
/MLd Use LIBCD.lib to create a debug single-threaded Executable   
/MT Use LIBCMT.lib to create a multithreaded executable   
/MTd Use LIBCMTD.lib to create a debug multithreaded executable   
  
Output file
  
Option    Action
/FA
/FA Create listing file
Set    listing filename
/Fd Rename program database file   
/Fe rename executable file   
/Fm create map file   
/Fo create object file   
/Fp specify precompiled header file name   
/FR
/FR generate browser file   
/Fx merge inserted code with source file   
  
debug
  
option    Action
/GS buffer security check   
/GZ same as /RTC1   
/RTC enable runtime error checking   
/Wp64 Detect 64-bit portability issues   
/Yd Put full debug info in all object files   
/Yl Insert PCH references when creating debug libraries   
/Z7 Generate C 7.0 compatible debug info   
/Zd Generate line numbers   
/Zi Generate full Debug information for   
  
preprocessor
  
options    Action
/AI Specify directories to search when resolving file references passed to #using directives   
/c Preserve comments during preprocessing   
/D Define constants and macros   
/E Copy preprocessor output to standard output   
/ EP Copy preprocessor output to standard output   
/Fl Preprocess specified include file   
/FU Force filename to be used as if it had been passed to the #using directive   
/I Search directory for include files   
/P Put preprocessor output write file   
/U remove predefined macros   
/U remove all predefined macros   
/X ignore standard include directories   
/ZI include debug information in "edit and continue" compatible program database   
  
language
  
option    effect
/noBool cancel C++ bool, true and false keywords   
/vd cancel or enable hidden vtordisp class members   
/vmb use best base   
for pointers to members /vmg use full generality for pointers to members   
/vmm declare multiple inheritance   
/vms declare single inheritance   
/vmv declare virtual inheritance   
/Za Disable language extensions   
/Zc Specify standard behavior under   
/Ze/Ze Enable language extensions   
/Zg Generate function prototypes   
/Zl Remove default library names from .obj files   
/Zp n encapsulate struct members   
/Zs Check syntax   
  
linkage only
  
Option    Effect
/F set stack size   
/LD create dynamic link library   
/LDd create debug dynamic link library   
/link pass specified options to LINK   
/MD compile with MSVCRT.lib to create multithreaded DLL   
/MDd compile with MSVCRTD.lib to create debug multithreaded DLL   
/ML compiles with LIBC.lib to create a single-threaded executable   
/MLd compiles with LIBCD.lib to create a debug single-threaded executable   
/MT Compile with LIBCMT.lib to create a multithreaded executable    / MTd    Compile with LIBCMTD.lib   
to create a debug multithreaded executable    /Yc Create precompiled headers    /Yd Put full debug information in all object files    /Yu Use precompiled headers during    build /YX Automatically handle precompiled header    miscellaneous options OPTIONS    @ Specify response file    /? List compilers options    /c compile but don't link    /H limit length of external (public) names    /HELP list compiler options    /J change default char type    /NOLOGO suppress logon copyright sign    /QI0f make sure Pentium 0F instructions have no problem    /QIfdiv FDIV, Workaround for Intel Pentium microprocessors with defective FPREM, FPTAN and FPATAN    instructions   
  

  






  

  











/showIncludes show a list of all include files during compilation   
/Tc
/Tc specify C source files   
/Tp
/Tp specify C++ source files   
/V set version string   
/w set warning level   
/w disable all warnings   
/Wall enable all warnings including Warnings disabled by default   
/WL Enables one-line diagnostics for error and warning messages when compiling C++ source code from the command line   
/Zm Sets the compiler's memory allocation limit The   
CL command line uses the following syntax:
  
CL [option...] file ... [option | file]... [lib...] [@command-file] [/link link-opt...]
  
The following table describes the meaning of the CL command input items   
  
option One or more CL options. Note that all options apply to all specified source files. Options are specified by a forward slash (/) or a dash (–). If an option takes arguments, the option's description specifies whether spaces are allowed between the option and the argument. Option names (except the /HELP option) are case-sensitive. For more information, see Order of CL Options.     
  
file The name of one or more source files, .obj files, or libraries. CL compiles the source files and passes the name of the .obj file and library to the linker. For more information, see CL Filename Syntax.     
  
lib One or more library names. CL passes these names to the linker.   
  
command-file A file containing multiple options and filenames. See the CL command file for more information.   
  
link-opt One or more linker options. CL passes these options to the linker.   
  
You can specify any number of options, file names, and library names, as long as the number of characters on the command line does not exceed 1024, a limit specified by the operating system.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326169657&siteId=291194637