原创 2010年05月28日 00:08:00




Building a Project from the Command Line


You can build a Visual C++ project from the command line without first exporting a makefile (MAKEFILE, or filename.mak) and using the NMAKE utility.


The basic command syntax is


msdev FileName [/MAKE "ProjectName – ConfigName | ALL"] [/REBUILD /CLEAN /NORECURSE /OUT LogFile /USEENV]


where FileName is the name of your project (.dsp) or workspace (.dsw) file.


For example, the following syntax deletes all intermediate files and then builds a project called MyProject:


msdev MyProject.dsp /MAKE "MyProject – Win32 Debug" /REBUILD


The following syntax builds a workspace that contains (at least) two projects, building the release configuration of MyProject1 and all configurations of MyProject2, and directing the build output to a file called MyWorkspace.log:


msdev MyWorkspace.dsw /MAKE "MyProject1 – Win32 Release" "MyProject2 – ALL" /OUT MyWorkspace.log


Note   Projects created in Visual C++ versions earlier than 5.0 must first be converted before you can build them from the command line. To convert a project, open it inside the development environment.


You can also build all configurations of a certain type within a single project, for example, if you have defined multiple types of Debug configurations. For more information, see "Building by Type of Configuration."


Tip   Type msdev /? /OUT FileName to pipe the command syntax to a file.


The /MAKE Option

The /REBUILD, /CLEAN and /NORECURSE options all modify the /MAKE option, and are meaningless without it. Also, unless you specify a FileName after msdev, any /MAKE options will be ignored. /MAKE requires at least one configuration.


Parameter          Description

A valid workspace or project filename. Must have an extension of .dsp or .dsw.


The project that contains the configurations you want to build. If Filename is a workspace file, ProjectName must be a part of that workspace.



Any valid project configuration, or all configurations for a particular project. To build all configurations, simply type "ALL" for the configuration value (must be uppercase). Corresponds to the choices available from the Settings For drop-down list in the Project Settings dialog box. 


Name of an optional file used to store the build output information (valid only with the /OUT option). 



Option              Operation
/MAKE "projectname1 – configuration1 | projectname1 – configuration2 | projectname2 – configuration1 | ALL"

Builds the specified configurations. The /CLEAN option modifies /MAKE so that the specified configurations are cleaned rather than built. 


Displays usage information for the msdev command.


Deletes intermediate files created during the build process for the specified configuration(s); does not build the project configuration(s). 


Cleans and builds the specified configuration(s), including all dependent projects. Takes precedence if both /CLEAN and /REBUILD are specified.


Builds the specified project configuration(s) without building any dependent projects.

/OUT logfile

Creates a log file for the build output, which includes such information as syntax errors and warnings. If you don't specify a filename, the build output information is displayed at the command prompt and is not saved to a file. 


Directs the build system to use environment variables for the current build session, rather than the directory settings specified on the Directories tab (Tools menu, Options command). The PATH, INCLUDE and LIB paths must be set correctly for the build to succeed when /USEENV is specified.

/EX MacroName

Invokes the named macro (if the associated .dsm file is not loaded, this command will fail).

Tip   Type msdev /USEENV at the command line to launch Visual C++ and use the environment variables for the duration of that IDE session.


Building by Type of Configuration

For any single project, you can build all configurations of a certain type. The build system uses limited pattern matching to recognize the name of the configuration you specify.


For example, if your project contains Debug and Release configurations for both regular and UNICODE applications, you can build both configurations for only the UNICODE application by issuing the following command:


msdev MyProject.dsp /MAKE "MyProject – UNICODE"


Or, if your project contains several types of Debug and Release configurations, you can build all of the Debug configurations:


msdev MyProject.dsp /MAKE "MyProject – DEBUG"


This pattern matching gives you even more flexibility when customizing your batch builds.





msdev MyProject.dsp /MAKE "MyProject – Release"



带你玩转Visual Studio——命令行编译C/C++程序

打开安装目录下的*VSDIR*\VC\bin可以看到一系列的可执行程序.exe和批处理文件,这些就是VS2010构建、编译、链接时要用到的工具。看一下几个主要的工具: cl.exe:编译程序 link...
  • luoweifu
  • luoweifu
  • 2015年11月15日 11:10
  • 37194

GNU libiconv-1.15和libintl-,VS2015工程和 Makefile 命令行编译文件

  • 2017年04月24日 22:35
  • 13.81MB
  • 下载


  • buyicn
  • buyicn
  • 2010年05月28日 00:08
  • 3061


转自 在vs2008下面提供了devenv.com命令行方式,我们可以从VS安装目录..\MicrosoftVi...
  • VictaminC
  • VictaminC
  • 2017年02月23日 16:21
  • 624


如何在命令行下编译创建VC程序转贴自常州VC编程网大多数MS Visual C++创建的程序用VC编译器是很容易编译并创建出可执行文...
  • huyoo
  • huyoo
  • 2004年09月23日 00:43
  • 4099


对于大多数在windows上写windows C/C++应用程序的人可能用的都是微软提供的VC++6.0或Visual Studio集成开发环境,但是对想为了更好地理解程序编译链接过程和习惯如linu...
  • wenzhou1219
  • wenzhou1219
  • 2013年08月30日 10:11
  • 5360

使用命令行对 ARM DS5 的工程进行编译

打开Windows Prompt,输入 SET path=C:\PROGRA~1\DS-5\bin;%SystemRoot%\system32;%SystemRoot% && "C:\PROGRA~...
  • kooder
  • kooder
  • 2014年10月10日 13:07
  • 2250


  • grey_csdn
  • grey_csdn
  • 2017年09月11日 22:50
  • 269


1.配置好VS 的环境变量 2.找出文件存放的位置例如 C:/Test/T.cpp 输入cl hello.cpp即可正常编译 注意文件的位置定位 可以用DOS 提供的CD 指令进入T.cpp的存放路径...
  • qq_25600055
  • qq_25600055
  • 2015年02月19日 21:55
  • 353


前言今天正好说到CL.exe的版本问题, 顺手做个用命令行编译VC6工程的试验. VC6的cl.exe最新版本是 12.0.8804 cl.exe版本不同, 生成的反汇编代码就不同(优化手段不同) D...
  • LostSpeed
  • LostSpeed
  • 2016年09月02日 18:20
  • 431