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
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
(/ 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
No link / w