c++ - 如何在 Windows 上用 Vim 运行 “:compiler msvc” 和 “:comp msbuild”?

标签 c++ windows visual-studio visual-c++ vim

我有 VS Express (2012) 桌面版。我是否也获得了 NMAKE.EXE 程序?

http://msdn.microsoft.com/en-us/library/dd9y37ha.aspx - The Microsoft Program Maintenance Utility (NMAKE.EXE) is a tool that builds projects based on commands contained in a description file.

当我在运行 :compiler msvc 之后运行 :make 时,shell 返回消息 'nmake' is not recognized作为内部或外部命令,”。如何使用这些命令编译 C++ 程序? NMAKE.EXE 工具与'nmake' 命令有关系吗?


http://msdn.microsoft.com/en-us/library/wea2sca5(v=vs.90).aspx - MSBuild is the new build platform for Microsoft and Visual Studio.

http://msdn.microsoft.com/en-us/library/dd293626.aspx - You can use the MSBuild tool to build a Visual C++ application from the command prompt. The build process is controlled by the information in a project file (.vcxproj) that you can create and edit. The project file specifies build options based on build stages, conditions, and events.

我是否也因为我的 VS Express for Desktop 而获得了 MSBuild 工具?当我在运行 :compiler msbuild 后使用 :make 时,shell 返回消息 “'msbuild' 未被识别为内部或外部命令,”msbuild.vimMSBuild 工具有关系吗?

The maintainer of msbuild.vim said, “I made the script for compiling C# projects using .NET... I don't know if it will work for C++...”

在 Vim 中如何通过在 :make 之前运行 :compiler msbuild 来编译?


关于编译一个程序如C++源文件,只有两个问题,关于这个问题,请详细说明回答:

  1. 如何使用:compiler msvc
  2. 如何使用:compiler msbuild

最佳答案

When I use :make after running :compiler msbuild, the shell returned the message “'msbuild' is not recognized as an internal or external command,”. Does msbuild.vim have a relation to MSBuild tool?

是的。

要在命令提示符中启用 msbuild,您只需将计算机上安装的 .net4 框架的路径添加到 PATH 环境变量中。 以下在 Windows 上对我有用:

您可以通过右键单击“计算机”访问环境变量,单击“属性”,然后单击左侧导航栏上的“高级系统设置”。在下一个对话框中单击“环境变量”,向下滚动到“PATH”并编辑它以包含您的框架路径(不要忘记在此处最后一个条目之后添加“;”。

作为引用,我的路径是 C:\Windows\Microsoft.NET\Framework64\v4.0.30319。 [1]

虽然我只将它用于 C# 项目,但我想它也适用于 C++。 请记住,您必须在项目目录 内运行 msbuild,否则 msbuild 将无法找到您的项目。

为了完整起见,这里是我的 vimrc 的片段(OP 已经通过电子邮件收到了)。

noremap <F4> :<C-U>silent make<CR>:redraw!<CR>
au FileType cs compiler msbuild

当然,我们总是欢迎对这个编译器脚本进行补丁和添加!

问候

[1]: How do I run msbuild from the command line using Windows SDK 7.1?

关于c++ - 如何在 Windows 上用 Vim 运行 “:compiler msvc” 和 “:comp msbuild”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18674226/

相关文章:

c++ - Qt:QFuture/QtConcurrent超时函数调用

c++ - 旋转控制不起作用

c++ - 你能不用 goto 重写这段代码吗

Python脚本到批处理文件

windows - 使用 python 在 selenium-chromedriver 中禁用地理定位

visual-studio - Visual Studio 多个启动项目 - 仅重启一个项目

c++ - Boost 如何序列化 STL 容器?

windows - 将 spark.local.dir 设置为不同的驱动器

visual-studio - 在 Visual Studio 2017 中隐藏生成的 js 文件

visual-studio - 如何防止 Project.params 保存时同步