C ++ Primer Learning Notes - VC7.1 CL Compile Options

xiaoxiao2021-03-06  71

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 hybrid model (default) / EH enabled C EH (W / SEH exception) / GD __CDECL call convention / EHC external "C" defaults to Nothrow / GR __fastcall call convention / GT generated fiber safety TLS access / gz __stdcall Call an agreement / gm [-] Enable minimum regeneration / GA to optimize / GL [-] enabled for Windows applications to enable link time code generation / GF Enable string pool / qifdiv [-] Enable Pentium FDIV repair / GF Enable read-only characters Strings / Qi0F [-] Enable Pentium 0x0f Repair / Gy Separation Linkr Function / Qifist [-] Use fist instead of ftol () / GZ Enable Stack Check (/ RTCS) / RTC1 Enable Quick Check (/ RTCSU) / GE All functions Force Stack Check / RTCC Convert to Smaller Type Check / GS [NUM] Control Stack Check / RTCS Stack Frame Runtime Check / GS Enable Security Check / RTCU Uninported Local Usage Check / GH Enable _penter function call / clr [: noAssembly] Create a time Library to the public language NOASSEMBLY - Do not generate an assembly - Output file - / fa [file] Named list file / fo Name Object File / FA [SC] Configuration Program Set List / Fp Named Premination File / FD [File] Named .PDB File / Fr [File] Named Source Browser File / Fe Named Executable File / Fr [File] Named Extension. SBR File / FM [file] Name Map File - Prerequisitator - / Ai

Add to Jum Set Search Path / FX Core the inserted code into file / fu Forced assembly / module / fi Naming Force included File / C does not extract notes / u Remove predefined macro / d {= | #} < TEXT> Defining Macro / U Remove all predefined macro / e Prerequisites to stdout / i Add to STDOUT / EP pre-processed to stdout, no # line / x ignore "standard location" / P pre-processed File - Language - / Zi Enable Debug Information / ZL Ignore. The default library name / zi enabled "Edit" / z1 enabled "Edit" / z7 Enable the Old Commissioning Information / ZS Only Syntax Checking / ZD Line Number Debug Information / VD {0 | 1} Disabled / Enable VTORDISP / ZP [N] Packaging Structure / VM Pointer Type / ZA Disabled Expansion (Double Index / OP) / Nobool Disable "Bool" Keyword / ZE Enable Extension (Default) / ZC: Arg1 [, Arg2] C language consistency, the parameters here can be: Forscope - Force the standard C for scope rules; wchar_t - wchar_t is this type, Not typedef-miscellaneous - @ Option Response File / WO WARNING N /?, / HELP Print this help message / w is N setting a warning level 1-4 / c to compile ,

No link / w Set warning level (default n = 1) / h Maximum external name length / WALL Enables all warnings / J default char types is unsigned / wp64 Enable 64-bit port positioning warning / NOLOGO Cancel Display Copyright Message / WX will be considered an error / showincludes display Include File Name / WL Enable Units Diagnostics / TC Create a file to .c / yc [file] Create .PCH file / tp Compile files as .CPP / YD puts debug information in each .Obj / Tc compiles all files to .c / yl [SYM] to insert all files into .PCH reference / TP Compile all files to .cpp / yu [file] .Pch file / v Settings String / YX [file] Auto .PCH / W Disable all warnings / y - Disable all PCH options / WD Disable Warning N / ZM maximum memory allocation (default %) / WE Treat a 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 and libcmt.lib link / MTD with libcmtd.lib debug library link / ld creation .dll / f Setup Stack Size / LDD Create .DLL Debt / Link [Loat Options and Library] Appendix II (More details , Can be found on the MSDN) Visual C # .NET Compiler Option - Output File - / Out: To generate XML document files - Enter files - / Recurse: According to the wildcard specification, including all files / Reference: from the specified assembly file quoted (Abbreviation: / R) / AddModule: Link the specified module to this assembly - Resources - / Win32RES: Specify Win32 Resource File (.res) / Win32ICON: 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 debugging 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 incremental compilation (abbreviation: / incr) - Errors and warnings - / warnaserror [ |] will give warning as an error / warn rating (0-4) (abbreviation: / w) / NOWARN: Disable a specific warning message - language - / checked [ |] generated overflow check / unsafe [

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

New Post(0)