当前位置:   article > 正文

在cmd命令行下使用VS Build Tools 编译运行C/C++源文件_vs_buildtools

vs_buildtools

Introduction

The following tools can help you to build a C/C++ project on the command line[10] .

CL
Use the compiler (cl.exe) to compile and link source code files into apps, libraries, and DLLs.

Link
Use the linker (link.exe) to link compiled object files and libraries into apps and DLLs.

MSBuild (Visual C++)
Use MSBuild (msbuild.exe) to build Visual C++ projects and Visual Studio solutions. This is equivalent to running the Build project or Build Solution command in the Visual Studio IDE.

DEVENV
Use DEVENV (devenv.exe) combined with a command-line switch—for example, /Build or /Clean—to perform certain build commands without displaying the Visual Studio IDE.

NMAKE
Use NMAKE (nmake.exe) to automate tasks that build Visual C++ projects by using a traditional makefile.

安装

   安装Visual Studio或Microsoft Visual C++ Build Tools。 我安装的是Visual Studio 2010 Express。 

CL


cl.exe is a tool that controls the Microsoft Visual C++ (MSVC) C and C++ compilers and linker. The compilers produce Common Object File Format (COFF) object (.obj) files. The linker produces executable (.exe) files or dynamic-link libraries (DLLs).

cl编译器命令选项

                         C/C++ COMPILER OPTIONS

                             -CODE GENERATION-

/GF enable read-only string pooling     /Gm[-] enable minimal rebuild
/Gy[-] separate functions for linker    /GS[-] enable security checks
/GR[-] enable C++ RTTI                  /GX[-] enable C++ EH (same as /EHsc)
/EHs enable C++ EH (no SEH exceptions)  /EHa enable C++ EH (w/ SEH exceptions)
/EHc extern "C" defaults to nothrow     
/fp:<except[-]|fast|precise|strict> choose floating-point model:
    except[-] - consider floating-point exceptions when generating code
    fast - "fast" floating-point model; results are less predictable
    precise - "precise" floating-point model; results are predictable
    strict - "strict" floating-point model (implies /fp:except)
/Qfast_transcendentals generate inline FP intrinsics even with /fp:except
/GL[-] enable link-time code generation /GA optimize for Windows Application
/Ge force stack checking for all funcs  /Gs[num] control stack checking calls
/Gh enable _penter function call        /GH enable _pexit function call
/GT generate fiber-safe TLS accesses    /RTC1 Enable fast checks (/RTCsu)
/RTCc Convert to smaller type checks    /RTCs Stack Frame runtime checking
/RTCu Uninitialized local usage checks  
/clr[:option] compile for common language runtime, where option is:
    pure - produce IL-only output file (no native executable code)
    safe - produce IL-only verifiable output file
    oldSyntax - accept the Managed Extensions syntax from Visual C++ 2002/2003
    initialAppDomain - enable initial AppDomain behavior of Visual C++ 2002
    noAssembly - do not produce an assembly
/Gd __cdecl calling convention          /Gr __fastcall calling convention
/Gz __stdcall calling convention        /GZ Enable stack checks (/RTCs)
/QIfist[-] use FIST instead of ftol()   
/hotpatch ensure function padding for hotpatchable images
/arch:<SSE|SSE2|AVX> minimum CPU architecture requirements, one of:
    SSE - enable use of instructions available with SSE enabled CPUs
    SSE2 - enable use of instructions available with SSE2 enabled CPUs
    AVX - enable use of Intel(R) Advanced Vector Extensions instructions
/Qimprecise_fwaits generate FWAITs only on "try" boundaries, not inside "try"
/Qsafe_fp_loads generate safe FP loads  

                              -OUTPUT FILES-

/Fa[file] name assembly listing file    /FA[scu] configure assembly listing
/Fd[file] name .PDB file                /Fe<file> name executable file
/Fm[file] name map file                 /Fo<file> name object file
/Fp<file> name precompiled header file  /Fr[file] name source browser file
/FR[file] name extended .SBR file       /Fi[file] name preprocessed file
/doc[file] process XML documentation comments and optionally name the .xdc file

                              -PREPROCESSOR-

/AI<dir> add to assembly search path    /FU<file> forced using assembly/module 
/C don't strip comments                 /D<name>{=|#}<text> define macro
/E preprocess to stdout                 /EP preprocess to stdout, no #line
/P preprocess to file                   /Fx merge injected code to file
/FI<file> name forced include file      /U<name> remove predefined macro
/u remove all predefined macros         /I<dir> add to include search path
/X ignore "standard places"             

                                -LANGUAGE-

/Zi enable debugging information        /Z7 enable old-style debug info
/Zp[n] pack structs on n-byte boundary  /Za disable extensions
/Ze enable extensions (default)         /Zl omit default library name in .OBJ
/Zg generate function prototypes        /Zs syntax check only
/vd{0|1|2} disable/enable vtordisp      /vm<x> type of pointers to members
/Zc:arg1[,arg2] C++ language conformance, where arguments can be:
    forScope[-] - enforce Standard C++ for scoping rules
    wchar_t[-] - wchar_t is the native type, not a typedef
    auto[-] - enforce the new Standard C++ meaning for auto
    trigraphs[-] - enable trigraphs (off by default)
/ZI enable Edit and Continue debug info 
/openmp enable OpenMP 2.0 language extensions

                              -MISCELLANEOUS-

@<file> options response file           /?, /help print this help message
/bigobj generate extended object format /c compile only, no link
/errorReport:option Report internal compiler errors to Microsoft
    none - do not send report                
    prompt - prompt to immediately send report
    queue - at next admin logon, prompt to send report (default)
    send - send report automatically         
/FC use full pathnames in diagnostics   /H<num> max external name length
/J default char type is unsigned        
/MP[n] use up to 'n' processes for compilation
/nologo suppress copyright message      /showIncludes show include file names
/Tc<source file> compile file as .c     /Tp<source file> compile file as .cpp
/TC compile all files as .c             /TP compile all files as .cpp
/V<string> set version string           /w disable all warnings
/wd<n> disable warning n                /we<n> treat warning n as an error
/wo<n> issue warning n once             /w<l><n> set warning level 1-4 for n
/W<n> set warning level (default n=1)   /Wall enable all warnings
/WL enable one line diagnostics         /WX treat warnings as errors
/Yc[file] create .PCH file              /Yd put debug info in every .OBJ
/Yl[sym] inject .PCH ref for debug lib  /Yu[file] use .PCH file
/Y- disable all PCH options             /Zm<n> max memory alloc (% of default)
/Wp64 enable 64 bit porting warnings    

                                -LINKING-

/LD Create .DLL                         /LDd Create .DLL debug library
/LN Create a .netmodule                 /F<num> set stack size
/link [linker options and libraries]    /MD link with MSVCRT.LIB
/MT link with LIBCMT.LIB                /MDd link with MSVCRTD.LIB debug lib
/MTd link with LIBCMTD.LIB debug lib    

优化选项

Parameter Function 功能
/O1 maximize speed 速度最大化
/O2 minimize space 空间最小化
/Ob inline expansion (default n=0) 内联展开(默认 n=0)
/Od disable optimizations (default) 禁用优化(默认值)
/Og enable global optimization 启用全局优化
/Oi[-] enable intrinsic functions 启用内部函数
/Os favor code space 代码空间优先
/Ot favor code speed 代码速度优先
/Ox maximum optimizations 最大优化
/Oy[-] enable frame pointer omission 可省略框架指针
-代码生成- 

/G380386 进行优化                    /Gh 启用 _penter 函数调用 
/G480486 进行优化                    /GH 启用 _pexit 函数调用 
/G5 为 Pentium 进行优化                  /GR[-] 启用 C++ RTTI 
/G6 对 PPro、P-II、P-III 进行优化        /GX[-] 启用 C++ EH (与 /EHsc 相同) 
/G7 对 Pentium 4 或 Athlon 进行优化      /EHs 启用 C++ EH (没有 SEH 异常) 
/GB 为混合模型进行优化(默认)              /EHa 启用 C++ EH(w/ SEH 异常) 
/Gd __cdecl 调用约定                     /EHc extern "C" 默认为 nothrow 
/Gr __fastcall 调用约定                  /GT 生成纤维安全   TLS 访问 
/Gz __stdcall 调用约定                   /Gm[-] 启用最小重新生成 
/GA 为 Windows 应用程序进行优化           /GL[-] 启用链接时代码生成 
/Gf 启用字符串池                          /QIfdiv[-] 启用 
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/224430
推荐阅读
相关标签
  

闽ICP备14008679号