How to run ": msvc compiler" and ": comp msbuild" from Vim on Windows?

I have VS Express (2012) for the desktop . I also purchased the program NMAKE.EXE?

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

When I run :make after run :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 NMAKE.EXE tool relate 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 create a Visual C ++ application from the command line. The build process is controlled by information in the project file (.vcxproj), which you can create and edit. The project file indicates the assembly parameters based on the assembly steps, conditions, and events.

I also purchased 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 relate to MSBuild ?

The compiler msbuild.vim said: "I created a script to compile C # projects using .NET ... I don’t know if this will work for C ++ ..."

How can I compile by running :compiler msbuild before :make in Vim?


There are only two questions in this question about compiling a program, such as the C ++ source file, and please answer with detailed instructions:

  • How to use :compiler msvc ?
  • How to use :compiler msbuild ?
+6
source share
2 answers

A quick search came across this: Getting started - C / C ++ programming with VIM , which can be a good starting point.

As user786653 mentioned, this does not work because your PATH does not include the nmake.exe directory. You can check your path with

 :echo $PATH 

Vim does not replace the basic functionality of the assembly; it simply wraps it.

  • Launch gVim from the Visual Studio Command Prompt
  • Create new files in the test directory:

    test.cpp

     #include <iostream> int main() { printf("hello world."); return 0; } 

    Makefile

     all: cl test.cpp 
  • install compiler (gVim)

     :compiler msvc 
  • compile (gVim)

     :make 

I do not have msbuild.vim script, but by installing "make program" in msbuild.exe

 :set makeprg=msbuild 

you can create by running: make from the directory containing the solution file (.sln) or project (.vxcproj), or you can use msbuild.exe at the command line :

 :make c:\Test\Test.sln /t:Rebuild /p:Configuration=Debug 

After compilation, you can view the result with

 :copen 

and move the errors with (n for the next, p for the previous and r for rewinding the first error)

 :cn :cp :cr 
+5
source

When I use: make after starting: the msbuild compiler, the shell returns the message "msbuild" is not recognized as an internal or external command. "Does msbuild.vim relate to the MSBuild tool?

Yes.

To enable msbuild on the command line, you just need to add the path to install .net4 on your machine into the PATH environment variable. The following worked for me on Windows:

You can access the environment variables by right-clicking on "Computer", click on "Properties" and click on "Advanced System Settings" in the left navigation bar. In the next dialog box, click "Environment Variables", scroll down to "PATH" and edit it to include your path to the framework (do not forget ";" after the last entry here.

For reference, my path was C:\Windows\Microsoft.NET\Framework64\v4.0.30319 . [1]

Although I use it only for C # projects, I believe that it will work for C ++ as well. Remember that you need to run msbuild inside the project directory, otherwise msbuild will not be able to find your project.

For completeness, here is a snippet of my vimrc (which the OP has already received by email).

 noremap <F4> :<CU>silent make<CR>:redraw!<CR> au FileType cs compiler msbuild 

Patches and additions to this compiler script are always welcome, of course!

Hello

[1]: How to start msbuild from the command line using the Windows SDK 7.1?

+4
source

Source: https://habr.com/ru/post/953388/


All Articles