C ++ Primer Learning Notes - Reprinted Mr. Glory Written CL Compile Options

xiaoxiao2021-03-06  76

And compared to compilation in IDE, the command line mode is faster and can avoid some additional information generated by the IDE. This article will introduce the Microsoft C / C / C # compiler command line mode setting and usage. The operating system is Windows 2000. One. Microsoft C / C Compiler Command Line Mode Setting Method 1 1. Refer to the following (according to your system, make a corresponding modification), write a batch file, assume that you are named vs.bat. @echo off set path = c: / winnt / system32; d: /vs.net/vc7/bin; d: /vs.net/common7/ide set include = d: /vs.net/vc7/include set lib = D: /VS.NET/VC7/LIB Description: a. The above environment variable string case does not matter, but the characters should be avoided. b. Plus C: / Winnt / System32, the purpose is to facilitate expansion commands such as HELP, and there is no direct relationship with this discussion topic. 2. Open a "command prompt" window, perform the following command: c: /> start c: /vc7.bat (according to your file path, make the corresponding modification) will create a new "command prompt" window, In this window, you can compile the C program. Specific usage, then said later. The disadvantage of this setting method is that the "Command Prompt" window can only be created in step 2, and once the window is turned off, then step 2 needs to be re-executed. Method 2 1. On the desktop "My Computer" icon, right-click, then execute the "Properties" menu command, or follow the "Start" - "Settings" - "Control Panel" step, double-click the system icon, will The System Features dialog box will pop up. Check the "Advanced" page, click the Environment Variable button, the environment variable setting window shown in Figure 1 will appear. (Note: Any user can add / delete / change the user environment variable, but only administrators can increase / delete / change the system environment variable. For each user of a specific computer, the user environment variable can be different) Figure 12. You can set it to a user environment variable, or you can set it as a system environment variable. Refer to the following, and see the interface shown in Figure 2. (According to your system, make the corresponding adjustment) PATH = C: / WinNT / System32; D: /VS.NET/VC7/bin; d: /vs.net/common7/ide include = d: /vs.net/ VC7 / include lib = d: /vs.net/vc7/lib Figure 2 and method is different, using this way, once the set is complete, you can once. No need to restart your computer, now open a "command prompt" window and try the CL command. Explanation: If your operating system is Windows 95/98, you can refer to the above description, directly edit the autoexec.bat file. two. Visual C # .NET compiler command line mode Sets the C # compiler command line mode setting method is similar, and there is no longer described, just add C: /Winnt/Microsoft.net/framework/v1.0.3705 after PATH. .

At present, my machine PATH environment variable is set as follows: Path = C: / WinNT / System32; D: /VS.NET/VC7/bin; d: /vs.net/common7/ide; c: /winnt/microsoft.net /Framework/v1.0.3705; 4/Vs.net/frameworksdk/bin; 4/bcc55/bin ;/roracle/ora81/bin three. Microsoft C / C compiler command line mode Usage Microsoft C / C compiler compile options numerous, in the "Command Prompt" window Type CL /? To view a complete list (see Appendix 1). For example, / gx enable C exception handling mechanism, / GR enables C RTTI, and so on. These compile options are not intended here to discuss these compilation options. The following is a sample file in my test directory f: / vStest: //1.cpp#include using namespace std; void main () {cout << "hello royal" << Endl;} you now You can enter the directory to perform the following compile command: f: / vstest> Cl / GX 1.cpp running program, will result in the following output: Hello Royal Compile Multiple files is also very simple, see Example: //2.cpp#include #include "3.cpp" Using Namespace std; void main () {CTest CT ("Hello www.royaloo.com"); cout << ct.str << Endl;} // 3.cpp # incrude Using Namespace Std; Ctest (String Strval): Str (String String) {} String Str;}; Perform the following compile command: f: / vstest> Cl / Gx 2.cpp 3.cpp It can also be compiled like this to specify the generated EXE name: f: / vstest> CL / gx /fehello.exe 2.cpp 3.cpp (generated hello.exe) Run program, the output is as follows: Hello www.royaloo.com four . Visual C # .NET Compiler Command Line Mode Type CSC /? You can view the full compilation option list (see Appendix 2). These compile options are not intended here to discuss these compilation options. However, it is necessary to explain that you don't need to use the / R: Compile option references the library file, you can compile most programs because the C # compiler defaults to Mscorlib.dll and the program specified in the CSC.RSP file. Library.

The file follows: # This file contains command-line options that the C # # command line compiler (CSC) will process as part # of every compilation, unless the "/ noconfig" option # is specified # Reference the common Framework libraries /. R: Accessibility.dll /r:MICROSoft.vsa.dll /r:system.configuration.install.dll /R :System.data.dll /R :system.design.dll /R :system.directoryServices.dll / r: System.dll /r :system.drawing.design.dll /r :system.drawing.dll /r:System.EnterpriseServices.dll /R :System.Management.dll /R: System.Messaging.dll / R: system.Messaging.dll / r: system. Runtime.remoting.dll /r :system.Runtime.Serialization.Formatters.soap.dll /r:System.Security.dll /R :system.serviceProcess.dll /R :System.Web.dll /R :System.Web. RegularExpressions.dll /R :System.Web.Services.dll /R :System.windows.Forms.dll /R: System.xml.dll is visible, it is a reference to many .NET standard libraries, if there is no sufficient reason, don't Modify this configuration file! But I modified the CSC.RSP file on my machine, and it's two lines in my tail: #nunit is a unit-testing framework for all .net languages ​​/R: D:/nunitv2.0/bin/nunit.framework .dll Note that there is no space in the file path. For example, NUnit 2.0 default installation main directory is Nuint v2.0, if not necessary changes (I changed to NUnitv2.0), will not be successfully reference NUnit.framework.dll, and will result in the entire CSC command line compiler Can't be used, be careful! If you want to cancel the Mscorlib.dll or CSC.RSP reference, you can use the / NostDLIB or / NOCONFIG to compile options.

The following is a sample file in my test directory f: / vStest; names.csusing system; namespace _4 {class class1 {[stathread] static void main (string [] args) {Console.writeline ("Hello Royal ");}}} Perform the following compile command: f: / vstest> CSC 4.CS running program, ie output: Hello Royal The following is an example of compiling multiple files: //5.csusing system; using _6; namespace _5 { Class class5 {[stathread] static void main (string [] args) {class6 c6 = new class6 ("Hello www.royaloo.com"); console.writeline (c6.str);}}} // 6.csuingsing system Namespace _6 {class class 6 {public class 6 {str = strign;} public string str;}} Execute the following compile command: f: / vstest> CSC 5.cs 6.cs can also be compiled, specify EXE file name: f: / vstest> CSC /out:Hello.exe 5.cs 6.cs running program, will output the following words: Hello www.royaloo.com Appendix 1 (more details, you can check MSDN) Microsoft C / C Compiler Option - Optimization - / O1 Minimization Space / OP [-] Improves Floating Sort Number Consistency / O2 Maximum Speed ​​/ OS Preferred Code Space / OA Assumption No Alias ​​/ OT Preferred Code Speed ​​/ OB Lianzhan (default n = 0) / OW assumes cross function alias / OD to disable optimization (default) / OX maximize options.

(/ OGITYB2 / GS) / OG Enable Global Optimization / OY [-] Enable Frame Pointer 省 省 省 启 启 启 内 内函 生 生 - - / 为 8 8 8 8 8 8 8 _ 8 _ 8 优 优 优 优 / 优 优 优 / 优 优 优 / 优 / 优 优[-] Enable C RTTI / G5 to optimize / GX [-] enable C EH (with / EHSC identical) / g6 for Pentium / GX [-] Enable C EH (with / EHSC identical) / G6 is PPRO, P-II, P-III Optimization / EHS Enable C EH (no SEH exception) / GB Optimized for Mixed Model (default) / EH Enable C EH (W / SEH exception) / GD__CDECL call convention / EHC external "C" defaults to nothrow / gr__fastcall call convention / GT Generate Fiber Safety TLS Access / GZ__STDCALL Call Convention / GM [-] Enables minimum regeneration / GA to optimize / GL [-] enable link time Code Generation / GF Enable String Pool / qifdiv [-] Enable Pentium FDIV Repair / GF Enable read-only string pool / Qi0f [-] Enable Pentium 0x0F Repair / Gy Separator Linkr Function / Qifist [-] Enable Stack Check (/ RTCS) / RTC1 Enable Quick Check (/ RTCSU) / GE to enable fast check (/ RTCSU) / gener Stack Check / RTCC Convert to Smaller Type Check / GS [NUM] Control Stack Check / RTCS Stack Frame Runtime Check / GS Enable Security Check / RTCU Uninitialized Local Usage Check / GH Enable _penter Function Call / CLR [ : noAssembly] Running time library for public language NOASSEMBLY - Do not generate assembly - output file - / fa [file] Named list file / fo Name Object file / fa [sc] Configuration program list / FP < File> Name Preface File / FD [File] Named .PDB File / Fr [File] Named Source Browser File / Fe Named Optical file / fr [file] named extension. SBR file / fm [file] Name Map File-Pre-Processor - / Ai

Add to Program Search Path / FX Merge the Code to File / FU Forced Upset / Module / Fi Naming Force Contains File / C Do not extract notes / u Remove predefined macro / d {= | #} Defining macro / U Remove all predefined macro / e Prerequisites to stdout / i Add to include Search Path / EP Prepare It is rationalistic, no # line / x ignores the "Standard Location" / P Prerequisites to File - Language - / Zi Enable Debug Information / ZL Ignore. The default library name / zi enabled "Edit" / zi in Obj Generate Function Prototype / Z7 Enable Old-style Debug Information / ZS Only Syntax Check / ZD Only Line Number Debug Information / VD {0 | 1} Disable / Enable VTORDISP / ZP [N] Packaging Structure on N-byte Boundary / VM < x> Pointer Type / ZA Disable Extensions (DE / OP) / Nobool Disables "Bool" Keyword / ZE Enable Extension (Default) / ZC: Arg1 [, Arg2] C language consistency, the parameters here can be : Forscope - Forced standard C ; wchar_t - wchar_t is this type, not typedef-miscellaneous - @ option Response file / wo WARNING N /?, / HELP Print this help message / W Sets WWF level 1-4 / c to compile, no link / w Set warning level (default n = 1) / h

Maximum external name length / Wall Enable all warnings / J Default char types is unsigned / wp64 Enable 64-bit port positioning warning / NOLOGO Cancel Display Copyright Message / WX will warn as an error / showincludes display Containing file name / WL Enable single line diagnostic / TC Compile the file to .c / yc [file] Create .PCH file / TP Compile the file to .cpp / yd will put the debug information in each .Obj / Tc compiles all files as .c / yl [SYM] Inserted into the test library. PCH reference / TP compiles all files to .cpp / yu [file] Use .PCH file / v Settings Version String / YX [file] automatic .PCH / w All Warning / Y - Disable All PCH Options / WD Disable WARNING N / ZM Maximum Memory Allocation (default is%) / WE Treats the warning N as an error - Link - / MD and MSVCRT .Lib link / MDD and MSVCRTD.LIB debug library link / ml with libc.lib link / MLD and libcd.lib debug library link / MT with libcmt.lib link / MTD with libcmtd.lib debug library link / LD creation .dll / F Setting Stack Size / LDD Creating .DLL Debital / Link [Limited Options and Library] Appendix II (More details, Accept MSDN) Visual C # .NET Compiler Option - Output File - / OUT: Output File Name (Default: The base name of the primary class or the base name of the first file) / Target: EXE generates the console executable (default) (abbreviation: / t: exe) / target: Winexe generates Windows Perform file (abbreviation: / t: winexe) / target: library generated library (abbreviation: / t: library) / target: module generation module (abbreviation: / t: module) / define: Definition Condition Compilation Symbol (Abbreviation: / D) / DOC: To generate XML document file - Enter file - / recurse: According to wildcard specification, including all files in the current directory and subdirectory / Reference: From the specified assembly file reference metadata (abbreviation: / r) / addmodule: link the specified module to this program - Resources - / Win32RES: Specify Win32 Resource File (.res) / Win32In: Using this icon Output / Resource: Embed a specified resource (abbreviation: / res) / linkResource: Connect the specified resource link to this program (abbreviation : / linkres) - Code Generation - / Debug [ | "Send Debug Information / Debug: {FULL | PDBONLY} Specify debug type (" full "is the default type, you can attach the debugger to the running program) / Optimize [ | -] Enable Optimization (Abbreviation: / O) / Incremental [ | -] Enable Increment Compiling (Abbreviation: / InCr) - Errors and Warnings - / WarnaserRor [ | -] Treats the warning as an error / WARN: Set Warning Level (0-4) (Abbreviation: / W) / NOWARN: Disable Specific Warning Messages - Language - / Checked [ | -] Generate Overflow Check / Unsafe [ | -] Allow "Insensk" code - Miscellaneous - @ Read Response Files to get more options / HELP Display this usage information (abbreviation: /?) / NOLOGO cancel compiler copyright information / noconfig Do not automatically contain CSC.RSP files - Advanced - / BaseAddress: <

转载请注明原文地址:https://www.9cbs.com/read-91563.html

New Post(0)