Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Microsoft C++ compiler without installing Visual Studio

In our team, the devs all have Visual Studio 2012, and we also use TFS2012 build. For space & manageability reasons, we don't install Visual Studio on our (many) build agents. This has worked so far with C# projects (csproj).

Now we want to add support for C++ project (vcxproj). These build on devs' machines, but not on the build agents - we get: X.vcxproj(31,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

I suppose this is because the C++ compiler & targets are only installed with VS.

  1. Is there a way to checkin just the compiler & targets, and set some property in our common.targets to point there?
  2. Failing that, what is the minimum I need to install on each build agent to support C++ compilation? The least I could find was VS Express, which is still too much to my liking.
like image 820
Jonathan Avatar asked Mar 14 '13 12:03

Jonathan


People also ask

Does Windows have inbuilt C compiler?

All Compilers & assemblers come as builtin with Windows without IDE and can be run from "the Windows Command prompt (cmd.exe)", so no extra downloads necessary; located in folder: C:\Windows\Microsoft.NET\Framework\vx.

Does C come with Visual Studio?

Visual Studio comes with its own C compiler, which is actually the C++ compiler. Just use the . c file extension to save your source code. You don't have to be using the IDE to compile C.

Do we need compiler for Visual Studio?

Microsoft C++ Compiler (MSVC)This is the default compiler for most Visual Studio C++ projects and is recommended if you are targeting Windows.


1 Answers

It is simple for C#, the ability to compile C# programs is innate in the framework, System.CodeDom, so just installing .NET is enough. Not so for C++. You'll at a minimum need to install the Windows SDK, half a gig. This includes the C++ compiler in SDK versions earlier than 8.0

However, you'll next get to fret about finding a way to get the class libraries on that machine. ATL and MFC for example. You can't just copy them, that violates the license. Much worse, Microsoft is not doing business the way they used to. They switched to a rapid-release cycle since VS2012 with updates shipping in a manner of months. These are not updates you can ignore, they add pretty major chunks to get C++11 implemented. Definitely the kind that your C++ programmers will want to use.

In general, the SDK version of the C++ compiler is just not in sync with VS version, the Windows team has no obligation to keep it updated. The one thing that a build machine should never do is run a different set of build tools than the ones used by the programmers. That makes a build break that can't be reproduced by a dev a big nasty point of contention. Unless you like making your life complicated, the message is clear. Don't do it, install VS.

like image 60
Hans Passant Avatar answered Oct 23 '22 02:10

Hans Passant