VC++用命令行编译工程

此文来源于MSDN,关于命令行编译VC++工程,比较浅显易懂。

-------------------------------------------------------------------------------------------

 

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.

 

Parameters
Parameter          Description
FileName              

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


ProjectName        

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

 

ConfigName         

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. 


LogFile                

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

 


Options

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.


/CLEAN

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


/REBUILD

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


/NORECURSE

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. 


/USEENV

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.

 

-------------------------------------------------------------------------------------------

补充,如果是编译Release,则可以写成如下:

 

msdev MyProject.dsp /MAKE "MyProject – Release"

 

命令行编译比较适合的是批量编译,特别是在构建时使用是很方便的。可以将编译命令写成批处理文件,编译时直接调用BAT即可!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用说明 微软最新的编程工具Visual Studio 2013 已经发布,想在该平台下使用WTL的话,目前还没有对应的安装文件(一般学者),本人将自己改写的文件上传到CSDN,供朋友使用。改写的版本为 WTL81_12085 第一步:下载文件包“WTL_81_12085_For_VS2013.rar”,解压后,有两个文件夹和两个文件 文件夹: Application (WTL添加到VS创建向导里的一些文件) 文件夹: Include (include就是WTL的头文件) 文件: setup120.js (安装脚本) 文件: 使用说明.txt 第二步:找到"VS安装目录\VC\VCWizards\AppWiz"这个目录, 如我电脑上就是"F:\Program Files\Microsoft Visual Studio 12.0\VC\VCWizards\AppWiz", 在这个目录下新建一个WTL文件夹,然后将Application文件夹和setup120.js拷贝到WTL文件夹下。 第三步:双击“setup120.js”进行安装,或者用命令行执行。 命令行操作方法如下: 运行CMD,执行如下代码: wscript //e:jscript "F:\Program Files\Microsoft Visual Studio 12.0\VC\VCWizards\AppWiz\WTL\setup110.js" 第四步:在“安装盘:\Program Files\Microsoft Visual Studio 12.0\VC”建一个WTL文件夹, 将解压出来的Include文件夹拷贝到此文件夹下面。 在编译工程时,将“安装盘:\Program Files\Microsoft Visual Studio 12.0\VC\WTL\Include”目录添加进包含目录。 第四步,可以不操作,只要编译时,将Include (WTL的头文件)目录添加进包含目录。 添加包含目录的操作为:打开工程属性页->配置属性->VC++目录->包含目录->编辑->写入路径->确定 也可以通过改写配置文件,添加为默认的包含路径,具体的方法请在网上找一下。 任何单位或个人转发本文件包请保留作者信息,谢谢! 水梦雪 [email protected]
[VS2005]解决“由于应用程序的配置不正确,应用程序未能启动,重新安装应用程序可能会纠正这个问题” 今天在准备发布用VS2005写的那个程序时,拷贝到我同事机器上,双击突然出现了“由于应用程序的配置不正确,应用程序未能启动,重新安装应用程序可能会纠正这个问题“,这个问题很让我意外,以前只出现过缺少DLL的情况,而这次出现这个问题,让我一时没办法。想想,无非是两个原因引起的,要么是他没有安装VS2005的原因,要么是我的程序里依赖了其它的一些库。于是百度一下,发现好多相关主题。我是按照这个帖子解决的: 在VS2005下用C++写的程序,在一台未安装VS2005的系统上, 用命令行方式运行,提示: “系统无法执行指定的程序” 直接双击运行,提示: “由于应用程序的配置不正确,应用程序未能启动,重新安装应用程序可能会纠正这个问题” 以前用VC6和VS2003的话, 如果缺少库文件,是会提示缺少“**.dll”,但是用VS2005却没有这样的提示。 自己实验了一下,感觉以下几种解决办法是可行的: 方法一: 在类似C:\Program Files\Microsoft Visual Studio 8\VC\redi st\Debug_NonRedist\x86\Microsoft.VC80.DebugCRT 下找到了下列文件: msvcm80d.dll msvcp80d.dll msvcr80d.dll Microsoft.VC80.DebugCRT.manifest 把这几个文件拷贝到目标机器上,与运行程序同一文件夹或放到system32下,就可以正确运行了。 其他release版、MFC程序什么的都是拷redist下相应文件夹下的文件就可以了,文件夹后都有标识! 方法二: 修改编译选项,将/MD或/MDd 改为 /MT或/MTd,这样就实现了对VC运行时库的静态链接,在运行时就不再需要VC的dll了。 方法三: 工程-》属性-》配置属性-》常规-》MFC的使用,选择“在静态库中使用mfc” 这样生成的exe文件应该就可以在其他机器上跑了。 方法四: 你的vc8安装盘上找到再分发包vcredist_xxx.exe和你的程序捆绑安装
YOLO高分设计资源源码,详情请查看资源内容中使用说明 YOLO高分设计资源源码,详情请查看资源内容中使用说明 YOLO高分设计资源源码,详情请查看资源内容中使用说明 YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值