I have VS Express (2012) for Desktop. Am I also acquired the NMAKE.EXE program?
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.
When I run :make
after running :compiler msvc
, the shell returned the message “'nmake' is not recognized as an internal or external command,”. How can I compile a C++ program using these commands? Does the tool NMAKE.EXE have a relation to the 'nmake' command?
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.
Did I also acquired the MSBuild tool because of my VS Express for Desktop? 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?
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++...”
How can I be able to compile by running :compiler msbuild
before :make
in Vim?
There are only two questions about compiling a program such as a C++ source file, on this question, and please answer with detailed instructions:
:compiler msvc
?:compiler msbuild
?To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-line options. Command-line options let you set properties, execute specific targets, and set other options that control the build process.
With Visual Studio 2019 and later, it's installed under the Visual Studio installation folder. For a typical default installation on Windows 10, MSBuild.exe is under the installation folder in MSBuild\Current\Bin. In the installer, make sure MSBuild tools for the workloads you use are selected, and choose Install.
By default, MSBuild will attempt to only run the TypeScript compiler when the project's source files have been updated since the last compilation.
TL;DR: Yes, you can build from the command line without using or even installing the IDE.
A quick search came across this: Getting started - C/C++ programming with VIM, which may be a good starting point.
As user786653 mentioned, this is failing because your PATH doesn't include the directory nmake.exe is in. You can inspect your path with
:echo $PATH
Vim doesn't replace the underlying build functionality, it simply wraps it.
Create new files in a test directory:
test.cpp
#include <iostream>
int main() {
printf("hello world.");
return 0;
}
Makefile
all:
cl test.cpp
set the compiler (gVim)
:compiler msvc
compile (gVim)
:make
I don't have the msbuild.vim script, but by setting the "make program" to msbuild.exe
:set makeprg=msbuild
you can build, by running :make from a directory containing a solution (.sln) or project (.vxcproj) file, or you can use the msbuild.exe command line like this:
:make c:\Test\Test.sln /t:Rebuild /p:Configuration=Debug
After compiling, you can examine the output with
:copen
and navigate the errors with (n for next, p for previous, and r for rewind to the first error)
:cn
:cp
:cr
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?
Yes.
To enable msbuild in Command Prompt, you simply have to add the path to the .net4 framework install on your machine to the PATH environment variable. The following worked for me on Windows:
You can access the environment variables by right clicking on 'Computer', click 'properties' and click 'Advanced system settings' on the left navigation bar. On the next dialog bog click 'Environment variables,' scroll down to 'PATH' and edit it to include your path to the framework (don't forget a ';' after the last entry in here.
For reference my path was C:\Windows\Microsoft.NET\Framework64\v4.0.30319
. [1]
Though I only use it for C# projects, I suppose it will work for C++ as well.
Remember that you have to run msbuild
inside the project directory, otherwise msbuild will not be able to find your project.
For the sake of completeness, here a snippet of my vimrc (which the OP already got by email).
noremap <F4> :<C-U>silent make<CR>:redraw!<CR>
au FileType cs compiler msbuild
Patches and additions to this compiler script are always welcome, of course!
Regards
[1]: How do I run msbuild from the command line using Windows SDK 7.1?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With