CMake and multiple Visual Studio installations using the same compiler version - c++

Scenario
A colleague set up a system a while back. They installed Visual Studio 15 Comminity Edition, merely to test the build process.
At some later point, another colleague was assigned to use that machine. Unbeknownst to them, there was Visual Studio 15 still installed on this machine, but since we have commercial licenses they installed Visual Studio 15 Professional in addition to the alrready installed Community Edition.
Behavior
It is of important note, that the Community Edition installation had the MFC toolset installed, while the Professional Edition installation had not.
Afterwards, the second colleague used our automated procedure to call CMake to first generate project files for Visual Studio, then used the standard command to execute the build pipeline:
cmake -G "Visual Studio 15 Win64" .
This resulted in compilation errors, because the Professional Edition did not have the MFC toolset available and thus the build pipeline failed. Yet within the IDE compilation was successful. After a short while was discovered, that opening "Visual Studio" via Windows start menu resulted in opening the Community Edition rather than the Professional Edition. Since the MFC toolset was then availale, IDE compilation was successful.
Question
Is the solution to this problem as obvious as it seems or does CMake have some way to determine which compiler to use?
Currently I have the following assumptions and would like to validate or refute them:
Each of the Visual Studio versions came with their own compiler for which the respective installers are able to enable/disable additional toolsets.
These two Visual Studio versions do not share the same comiler. (That they do not share toolsets does seem obvious)
CMake has no additional settings to declare which of the compilers of these distinct Visual Studio installations is to be used to execute the build pipeline.
The reason CMake utilized the Professional Edition compiler to execute the build pipeline is merely because the Professional version was installed second, likely overriding a path (registry entry?) CMake uses to find the compiler.
Is this assessment correct? Did something else happen here?

Related

SCons detects Visual C++ v14.2 (2019) but not v14.1 (2017)

I need to build a dependency that uses SCons, and I need to build it with VC++2017, because another dependency I have cannot be built with VC++2019.
SCons successfully detects VC++2019 (v14.2), but not VC++2017 (v14.1):
c:\Python27\Scripts\scons [...] --msvc-version=14.1 [...]
scons: Reading SConscript files ...
scons version: 3.1.1
python version: 2 7 13 'final' 0
scons: warning: VC version 14.1 not installed. C/C++ compilers are most likely not set correctly.
Installed versions are: ['14.2', '14.0', '11.0']
[...]
C++ compiler $CC does not work
I have installed Visual Studio 2019 Enterprise as well as Visual Studio 2019 Build Tools, and for both, I have installed the platform tools / compiler for v14.1 and x86/x64. Compiling with the VC++2017 platform tools works fine in Visual Studio 2019 as well as using MSBuild, so the problem seems to be with SCons only.
How does SCons detect VC++2017 and VC++2019 and where should I start looking for the problem?
(There are old threads about this, but most of them are about people wondering why the "classic" detection/config methods using registry and vcvars.bat no longer work, so these are not helpful)
For current scons, it will believe what it gets back from vswhere.exe for the versions where that tool is considered definitive - 2017 and 2019. You can try seeing what that gives you.
vswhere -products * -property installationPath
That information is used to help locate the desired vars.bat file which imports the seetings needed.
I have found a perfect and simple solution:
Open file MSCommon/vc.py, find line: vc_pdir = os.path.join(vsdir[0], 'VC')
Change [0] to [1]
Re-build, the python will use vs2017
The reason is: if you install multi vs versions, the vsdir[0] is the highest one
Update: This is still (2021-09-16) an issue, and a simple workaround may be this answer - My answer also has a workaround, but it is more complicated and mostly for educational purposes on how recent versions of VC++ compilers can be detected and are (not properly) detected by SCons. You may also want to use my workaround if you are creating a build script for a build server or multiple development machines with varying setups.
The current version of SCons does not support selecting MSVC v14.1 (aka "Visual C++ 2017") if Visual Studio 2019 is installed, but Visual Studio 2017 is not. I confirmed this by looking at the code of SCons (see below).
An alternative approach is to use the --msvc-script option instead of --msvc-version.
In the MSVC installation folder, typically c:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\, you will find a file called vcvarsall.bat. If you run this without arguments, you will see that you can give it arguments for target platform and tools version, e.g.,
vcvarsall.bat x86 10.0.17763.0 -vcvars_ver=14.1
to compile for x86 (32-bit), Windows SDK version 10.0.17763.0 and tools version 14.1 (Visual C++ 2017).
Once you have found a command line for vcvarsall.bat that suits you, put it into a new BAT file that you create, say myvcconfig.bat (You have to use the complete path to vcvarsall.bat), then use the following command-line switch to SCons: --msvc-script=myvcconfig.bat.
*** Notes ***
Some parameters to SCons are redundant and will not work with --msvc-script, for example --32. SCons will tell you about them, so just remove them from the command-line.
The installation path of Visual Studio may be different from the one I provided above. You can find the installation path using Microsoft's own VSWhere tool. See also Locate Visual Studio
Visual Studio 2019 and Visual Studio Build Tools 2019 are separate installations with separate build tools. You can detect and use the vcvarsall.bat files of either ones. For example, if you are setting up a toolchain for a build server, you may want to use Visual Studio Build Tools 2019. If you just want to build one library one time (as in my case), just use the Visual Studio that is installed on your dev machine.
In case you are interested in how SCons detects MSVC and why it doesn't work, you can look at the source code in SCons/Tool/MSCommon/vc.py. You can clone the SCons GIT repository.
UPDATE: The following comment in vc.py (as of 2021-09-16) shows why this is still an issue in SCons and why this workaround is needed if you have both VC2017 and VC2019 compilers installed:
# make sure the cl.exe exists meaning the tool is installed
if ver_num > 14:
# 2017 and newer allowed multiple versions of the VC toolset to be
# installed at the same time. This changes the layout.
# Just get the default tool version for now
#TODO: support setting a specific minor VC version
Direct link (valid at time of writing)

How to build C++ project in Visual Studio 2015 and Visual Studio 2002 at one time

I need to build my C++ projects in two environments:
Visual Studio 2015 (VS2015) installed on Windows 10 x64
Visual Studio 2002 (VS2002) installed on Windows XP
Now every time I need to trigger to build my projects twice on 2 PC and this way is not sufficient for me.
I do some research before and someone suggest to install multiple compiler in one PC, but the problem is that VS2002 is too old to be installed on Windows 10 x64.
I am looking for any method or software tool that I can trigger the build once then I can build my projects on both VS2015 and VS2002 (e.g. if I can install both VS2015 and VS2002 in one PC, I can write a simple batch file to build my project in both compiler).
EDIT:
This answer is outdated because of clarification that the software is installed on two physically different machines.
If you have both VS .NET 2002 and VS2015 installed then you already have two compilers installed and they will be installed in two different places. You then should just be able to write a batch file to call each version of cl.exe (making sure the paths are absolute) and compile/link/build each project.

The build tools for Visual Studio 2008 (Platform Toolset = 'v90') cannot be found

I'm trying to build project c++ on vs2017 but there error appear:
"The build tools for Visual Studio 2008 (Platform Toolset = 'v90') cannot be found " after navigation, I must download VS 2008 I have installed it, but problem still exist .
any Suggestion ?
You need:
An MSVC 9.0 compiler toolchain
https://wiki.python.org/moin/WindowsCompilers lists the products that have it:
VS 2008, "Visual C++" feature and "x64 compilers and tools" subfeature
Express edition only has x86 compilers
Do install SP1 on top of VS2008 -- in vanilla VS2008 installer, installation for many features, including x64 compilers, is broken
WinSDK 6.1
WinSDK 7.0
"Visual C++ Compiler for Python 2.7" package
MsBuild 4.0 toolset configuration files for the above toolchain. (These are the directories c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\<arch>\PlatformToolsets\v90\ with .props and .targets files in them)
The only product I know that has this package is VS 2010 ("Visual C++" feature and "x64 compilers and tools" subfeature).
(WinSDK 7.1 technically has it, too, but its setup is riddled with bugs and broken on an x64 system.)
(You can bypass the buggy installer though if you install <GRMSDK_EN_DVD.iso>\Setup\vc_stdx86\vc_stdx86.msi directly. Despite the name, it has toolset files for all 3 platforms.)
"Visual C++ Compiler for Python 2.7" package is not supported by these toolset configuration files. So if you use it, you'll need to either manually specify its location in one of registry values specified in .props, or modify .props to also look in HKLM\Software\Microsoft\DevDiv\VCForPython.
The projects are targeting the v90 platform toolset. The solution is to either open the .sln file with VS2008 (i.e. use the right tool), or spend some time updating the projects to target the latest platform toolset (i.e. VS2017). To do that, just right click each project, and go to Properties, then look at General | Windows SDK Version. You may have to fix compilation / linker errors following the project upgrade.
It is possible to upgrade the project file from the command line without opening it in Visual Studio. I was running into the same issue, and found another solution in the Microsoft documentation for Visual Studio (https://learn.microsoft.com/en-us/visualstudio/ide/reference/upgrade-devenv-exe?view=vs-2017).
Here are the steps:
Open the developer command prompt for you version of Visual Studio, e.g. 'Developer Command Prompt for VS 2017'.
Navigate to the directory of your project file.
Execute the following command: devenv myproject.sln /upgrade

how to get VS2013 c++ compiler to use with Qt without installing VS2013 [duplicate]

As per the title. I don't want to download the entire Visual C++ installer, only "cl.exe" and the other programs required for compiling and linking C++ programs on Windows.
As said, there is no way to do that. You need to download the entire 4-6GB+ bundle. MS deployment is a botch.
There is no need, however, to actually install everything. If you're up to some manual installation, you can extract individual components from the bundle and put them all in a more organized directory tree.
For example, I've found the following set to be the bare minimum needed for using the current MSVC2013 compilers in a x86 environment:
vc_compilerCore86.msi: MSVC toolchain;
vc_compilerCore86res.msi: MSVC toolchain MUI resources;
vc_librarycore86.msi: MSVC library stuff;
vc_LibraryDesktopX86.msi: More MSVC library stuff;
Windows Software Development Kit for Windows Store Apps-x86_en-us.msi: Windows SDK files and related tools (rc.exe, mt.exe, etc.);
Windows Software Development Kit-x86_en-us.msi: More Windows SDK files (specifically, WinSock2.h, WS2_32.lib, maybe others).
Remember that you can extract the contents of a MSI file by running msiexec /a <msifile> TARGETDIR="<path>" (jot a /quiet parameter if you're batching). Of course, you can also put more into your package by investigating the MSI files inside the bundle. In particular, the above set is missing the latest MSBuild tools, since I don't care for them. Stuff is often scattered around between multiple MSIs cluelessly, so good luck.
I've got a 50MB (!!!) 7z-file containing this set for local deployment, though I cannot share this publicly due to Microsoft licensing restrictions.
UPDATE:
This is the list of MSI files for MSVC2015 tools, headers and libraries:
packages\VisualC_D14\VC_Tools.Core\VC_Tools.Core.msi
packages\VisualC_D14\VC_Tools.Core.Res\VC_Tools.Core.Res.msi
packages\VisualC_D14\VC_Tools.X86.Base\VC_Tools.X86.Base.msi
packages\VisualC_D14\VC_Tools.X86.Base.Res\VC_Tools.X86.Base.Res.msi
packages\VisualC_D14\VC_Tools.X86.Nat\VC_Tools.X86.Nat.msi
packages\VisualC_D14\VC_Tools.X86.Nat.Res\VC_Tools.X86.Nat.Res.msi
packages\VisualC_D14\VC_Tools.X86.X64\VC_Tools.X86.X64.msi
packages\VisualC_D14\VC_Tools.X86.X64.Res\VC_Tools.X86.X64.Res.msi
packages\VisualC_D14\VC_PremTools.X86.Base\VC_PremTools.X86.Base.msi
packages\VisualC_D14\VC_PremTools.X86.Base.Res\VC_PremTools.X86.Base.Res.msi
packages\VisualC_D14\VC_PremTools.X86.Nat\VC_PremTools.X86.Nat.msi
packages\VisualC_D14\VC_PremTools.X86.Nat.Res\VC_PremTools.X86.Nat.Res.msi
packages\VisualC_D14\VC_PremTools.X86.X64\VC_PremTools.X86.X64.msi
packages\VisualC_D14\VC_PremTools.X86.X64.Res\VC_PremTools.X86.X64.Res.msi
packages\VisualC_D14\VC_CRT.Headers\VC_CRT.Headers.msi
packages\VisualC_D14\VC_CRT.X86.Desktop\VC_CRT.X86.Desktop.msi
packages\VisualC_D14\VC_CRT.X86.Store\VC_CRT.X86.Store.msi
packages\VisualC_D14\VC_CRT.X64.Desktop\VC_CRT.X64.Desktop.msi
packages\VisualC_D14\VC_CRT.X64.Store\VC_CRT.X64.Store.msi
packages\VisualC_D14\VC_CRT.Redist.Res\VC_CRT.Redist.Res.msi
packages\VisualC_D14\VC_CRT.Redist.X86\VC_CRT.Redist.X86.msi
packages\VisualC_D14\VC_CRT.Redist.X64\VC_CRT.Redist.X64.msi
packages\VisualC_D14\VC_ATL.Headers\VC_ATL.Headers.msi
packages\VisualC_D14\VC_ATL.X86\VC_ATL.X86.msi
packages\VisualC_D14\VC_ATL.X64\VC_ATL.X64.msi
packages\VisualC_D14\VC_MFC.Headers\VC_MFC.Headers.msi
packages\VisualC_D14\VC_MFC.X86\VC_MFC.X86.msi
packages\VisualC_D14\VC_MFC.X64\VC_MFC.X64.msi
packages\VisualC_D14\VC_PGO.Headers\VC_PGO.Headers.msi
packages\VisualC_D14\VC_PGO.X86\VC_PGO.X86.msi
packages\VisualC_D14\VC_PGO.X64\VC_PGO.X64.msi
packages\Win10_UniversalCRTSDK\Universal CRT Headers Libraries and Sources-x86_en-us.msi
And this is the list of MSI files for WinSDK10 tools, headers and libraries (downloaded separately):
Installers\Windows SDK Desktop Headers Libs Metadata-x86_en-us.msi
Installers\Windows SDK Desktop Tools-x86_en-us.msi
Installers\Windows SDK for Windows Store Apps Headers Libs-x86_en-us.msi
Installers\Windows SDK for Windows Store Apps Tools-x86_en-us.msi
All of this include stuff for both x86 and x64 (I haven't considered ARM or IA64). Both bundles compressed with LZMA will yield a 185MB file.
Locked. There are disputes about this answer’s content being resolved at this time. It is not currently accepting new interactions.
In 2014 you could not download the Visual C++ compiler alone from Microsoft.
It used to be that you could. Then it used to be that you could get it in the Platform SDK. Then you could only get it by installing Visual Studio.
Happily, at that time, the compiler that was bundled with Visual Studio Express for Desktop (the free version of Visual Studio at the time) was, and is, the very same that you get with Professional or Universal editions.
In November 2015 Microsoft again started providing the compiler tools in a free-standing package called the Visual C++ Build Tools.
Microsoft writes:
” the C++ Build Tools installer will not run on a machine with Visual Studio 2015 already installed on it. The reverse (i.e. upgrade to Visual Studio) is supported.
The long term situation is, as always, unclear. And, disclaimer: I have not used the build tools myself – I would have to uninstall Visual Studio first.
I ended up using Chocolatey, which has a package for Visual C++ Build Tools.
This command:
choco install visualcpp-build-tools
will install the latest 2017 version, but you can select one of the older versions, which include the 2015 release.
After the installation Visual Studio 2017 folder is added to the Programs menu. It includes shortcuts to various developer command prompts with cl.exe and other tools in the path.
As of 2019 Microsoft offers Visual Studio Build Tools which only includes the compiler, build tools and SDK. It's hidden in the all downloads list.
Update: The Visual C++ 2015 Build Tools are located here: http://landinghub.visualstudio.com/visual-cpp-build-tools
The Visual C++ 2017 Build Tools are now part of the regular VS 2017 installer. Just select the workloads you need. Information is on the same page.
This link is preferred to the blog links below as it's the official landing page and will be kept up-to-date.
I'm on the C++ team. If you have any questions about using the VC++ Build Tools or about MSVC in general, feel free to email me. My email is my StackOverflow user name #microsoft.com.
Once I tried to do same this as you. But MS doesn't provide isolated compiler. So if you need MS C++ compiler you must need to install the VS. But if you like to adventure. there is a tricky way to do that. Try it here.
Chrees!
You can use MSVC compiler without Visual Studio and the latest version is available here:
http://www.microsoft.com/en-us/download/details.aspx?id=41151
Also here's a website which details the command line options for the compiler:
http://msdn.microsoft.com/en-us/library/9s7c9wdw.aspx
As of the time of writing (June 23, 2021), the following info is taken from Configure VS Code for Microsoft C++.
Here is the important quote:
You can also install just the C++ Build Tools, without a full Visual
Studio IDE installation. From the Visual Studio Downloads page, scroll
down until you see Tools for Visual Studio under the All downloads
section and select the download for Build Tools for Visual Studio.
This will launch the Visual Studio Installer, which will bring up a
dialog showing the available Visual Studio Build Tools workloads.
Check the C++ build tools workload and select Install.
Note: You can use the C++ toolset from Visual Studio Build Tools along
with Visual Studio Code to compile, build, and verify any C++ codebase
as long as you also have a valid Visual Studio license (either
Community, Pro, or Enterprise) that you are actively using to develop
that C++ codebase.
As what stated in visual c++ 2015 tools for windows desktop
Mount your VS2015.iso
You can find all packages at your mounted location E:\packages | G:\packages
Navigate to Control Panel.
Right-Click at your VS2015 and choose change-modify
Check the Visual C++ boxes as stated in the link.
Click on Modify.
If installer fail to update, copy the mounted directory location and paste on it.
Click Retry button.
On March 21, 2022, the best I could figure out was to find the "Visual Studio Community" free download (required logging in with Microsoft account). There was no longer any "just give me the damn Build Tools" concept, but there is the promise that you just download an installer and then pick. So I downloaded the installer and ran it.
Of course, none of the top-level options are suitable for "just give me the damn Build Tools", so I pick the "Individual Components" option. This supplies an incredibly large list of things I don't want, but buried within it I find "MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)" which looks hopeful. I check that box and I'm informed they will give me also "Visual Studio code editor".
I'm sternly warned that I'm installing "without workloads", which seems to be some additional crap that the "Visual Studio core editor" I'm never going to use wants. I decline the additional bloatware. Some gigabytes later, it says I'm "Done installing" but warns "We recommend rebooting soon to clean up any remaining files."
After decades of (re-)writing scripts to locate the Microsoft compiler, I bow to Microsoft's superior ability to keep breaking any easy method of automating this process. Whenever I install the Microsoft compiler on a system, I manually set a system-wide environment variable that points to the Microsoft batch file for setting shell environment variables for the tools. Today's machine is a no-license (hey, Microsoft sucks the same way, just not as much!) Windows 10, and that is <Winkey>-x | System | Advanced System settings | Environment Variables
I create a variable called RLBVCVARS and set it to (in this particular case) c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat My portable Windows dev environment keeps an alias that points to that so, I can mostly pretend Microsoft doesn't constantly introduce breaking changes to their installation schemes. I think you have to reboot for a "system" environment variable to take effect, but hey, Microsoft wants you to reboot after installing anything anyway, so no biggy.
First compile says can't find "io.h". Back to the installer. Let's try adding "Windows 10 SDK" (3 versions to choose from!). A GB or so later, I have an io.h and can build my current project. Onward and upward.

Can I download the Visual C++ Command Line Compiler without Visual Studio?

As per the title. I don't want to download the entire Visual C++ installer, only "cl.exe" and the other programs required for compiling and linking C++ programs on Windows.
As said, there is no way to do that. You need to download the entire 4-6GB+ bundle. MS deployment is a botch.
There is no need, however, to actually install everything. If you're up to some manual installation, you can extract individual components from the bundle and put them all in a more organized directory tree.
For example, I've found the following set to be the bare minimum needed for using the current MSVC2013 compilers in a x86 environment:
vc_compilerCore86.msi: MSVC toolchain;
vc_compilerCore86res.msi: MSVC toolchain MUI resources;
vc_librarycore86.msi: MSVC library stuff;
vc_LibraryDesktopX86.msi: More MSVC library stuff;
Windows Software Development Kit for Windows Store Apps-x86_en-us.msi: Windows SDK files and related tools (rc.exe, mt.exe, etc.);
Windows Software Development Kit-x86_en-us.msi: More Windows SDK files (specifically, WinSock2.h, WS2_32.lib, maybe others).
Remember that you can extract the contents of a MSI file by running msiexec /a <msifile> TARGETDIR="<path>" (jot a /quiet parameter if you're batching). Of course, you can also put more into your package by investigating the MSI files inside the bundle. In particular, the above set is missing the latest MSBuild tools, since I don't care for them. Stuff is often scattered around between multiple MSIs cluelessly, so good luck.
I've got a 50MB (!!!) 7z-file containing this set for local deployment, though I cannot share this publicly due to Microsoft licensing restrictions.
UPDATE:
This is the list of MSI files for MSVC2015 tools, headers and libraries:
packages\VisualC_D14\VC_Tools.Core\VC_Tools.Core.msi
packages\VisualC_D14\VC_Tools.Core.Res\VC_Tools.Core.Res.msi
packages\VisualC_D14\VC_Tools.X86.Base\VC_Tools.X86.Base.msi
packages\VisualC_D14\VC_Tools.X86.Base.Res\VC_Tools.X86.Base.Res.msi
packages\VisualC_D14\VC_Tools.X86.Nat\VC_Tools.X86.Nat.msi
packages\VisualC_D14\VC_Tools.X86.Nat.Res\VC_Tools.X86.Nat.Res.msi
packages\VisualC_D14\VC_Tools.X86.X64\VC_Tools.X86.X64.msi
packages\VisualC_D14\VC_Tools.X86.X64.Res\VC_Tools.X86.X64.Res.msi
packages\VisualC_D14\VC_PremTools.X86.Base\VC_PremTools.X86.Base.msi
packages\VisualC_D14\VC_PremTools.X86.Base.Res\VC_PremTools.X86.Base.Res.msi
packages\VisualC_D14\VC_PremTools.X86.Nat\VC_PremTools.X86.Nat.msi
packages\VisualC_D14\VC_PremTools.X86.Nat.Res\VC_PremTools.X86.Nat.Res.msi
packages\VisualC_D14\VC_PremTools.X86.X64\VC_PremTools.X86.X64.msi
packages\VisualC_D14\VC_PremTools.X86.X64.Res\VC_PremTools.X86.X64.Res.msi
packages\VisualC_D14\VC_CRT.Headers\VC_CRT.Headers.msi
packages\VisualC_D14\VC_CRT.X86.Desktop\VC_CRT.X86.Desktop.msi
packages\VisualC_D14\VC_CRT.X86.Store\VC_CRT.X86.Store.msi
packages\VisualC_D14\VC_CRT.X64.Desktop\VC_CRT.X64.Desktop.msi
packages\VisualC_D14\VC_CRT.X64.Store\VC_CRT.X64.Store.msi
packages\VisualC_D14\VC_CRT.Redist.Res\VC_CRT.Redist.Res.msi
packages\VisualC_D14\VC_CRT.Redist.X86\VC_CRT.Redist.X86.msi
packages\VisualC_D14\VC_CRT.Redist.X64\VC_CRT.Redist.X64.msi
packages\VisualC_D14\VC_ATL.Headers\VC_ATL.Headers.msi
packages\VisualC_D14\VC_ATL.X86\VC_ATL.X86.msi
packages\VisualC_D14\VC_ATL.X64\VC_ATL.X64.msi
packages\VisualC_D14\VC_MFC.Headers\VC_MFC.Headers.msi
packages\VisualC_D14\VC_MFC.X86\VC_MFC.X86.msi
packages\VisualC_D14\VC_MFC.X64\VC_MFC.X64.msi
packages\VisualC_D14\VC_PGO.Headers\VC_PGO.Headers.msi
packages\VisualC_D14\VC_PGO.X86\VC_PGO.X86.msi
packages\VisualC_D14\VC_PGO.X64\VC_PGO.X64.msi
packages\Win10_UniversalCRTSDK\Universal CRT Headers Libraries and Sources-x86_en-us.msi
And this is the list of MSI files for WinSDK10 tools, headers and libraries (downloaded separately):
Installers\Windows SDK Desktop Headers Libs Metadata-x86_en-us.msi
Installers\Windows SDK Desktop Tools-x86_en-us.msi
Installers\Windows SDK for Windows Store Apps Headers Libs-x86_en-us.msi
Installers\Windows SDK for Windows Store Apps Tools-x86_en-us.msi
All of this include stuff for both x86 and x64 (I haven't considered ARM or IA64). Both bundles compressed with LZMA will yield a 185MB file.
Locked. There are disputes about this answer’s content being resolved at this time. It is not currently accepting new interactions.
In 2014 you could not download the Visual C++ compiler alone from Microsoft.
It used to be that you could. Then it used to be that you could get it in the Platform SDK. Then you could only get it by installing Visual Studio.
Happily, at that time, the compiler that was bundled with Visual Studio Express for Desktop (the free version of Visual Studio at the time) was, and is, the very same that you get with Professional or Universal editions.
In November 2015 Microsoft again started providing the compiler tools in a free-standing package called the Visual C++ Build Tools.
Microsoft writes:
” the C++ Build Tools installer will not run on a machine with Visual Studio 2015 already installed on it. The reverse (i.e. upgrade to Visual Studio) is supported.
The long term situation is, as always, unclear. And, disclaimer: I have not used the build tools myself – I would have to uninstall Visual Studio first.
I ended up using Chocolatey, which has a package for Visual C++ Build Tools.
This command:
choco install visualcpp-build-tools
will install the latest 2017 version, but you can select one of the older versions, which include the 2015 release.
After the installation Visual Studio 2017 folder is added to the Programs menu. It includes shortcuts to various developer command prompts with cl.exe and other tools in the path.
As of 2019 Microsoft offers Visual Studio Build Tools which only includes the compiler, build tools and SDK. It's hidden in the all downloads list.
Update: The Visual C++ 2015 Build Tools are located here: http://landinghub.visualstudio.com/visual-cpp-build-tools
The Visual C++ 2017 Build Tools are now part of the regular VS 2017 installer. Just select the workloads you need. Information is on the same page.
This link is preferred to the blog links below as it's the official landing page and will be kept up-to-date.
I'm on the C++ team. If you have any questions about using the VC++ Build Tools or about MSVC in general, feel free to email me. My email is my StackOverflow user name #microsoft.com.
Once I tried to do same this as you. But MS doesn't provide isolated compiler. So if you need MS C++ compiler you must need to install the VS. But if you like to adventure. there is a tricky way to do that. Try it here.
Chrees!
You can use MSVC compiler without Visual Studio and the latest version is available here:
http://www.microsoft.com/en-us/download/details.aspx?id=41151
Also here's a website which details the command line options for the compiler:
http://msdn.microsoft.com/en-us/library/9s7c9wdw.aspx
As of the time of writing (June 23, 2021), the following info is taken from Configure VS Code for Microsoft C++.
Here is the important quote:
You can also install just the C++ Build Tools, without a full Visual
Studio IDE installation. From the Visual Studio Downloads page, scroll
down until you see Tools for Visual Studio under the All downloads
section and select the download for Build Tools for Visual Studio.
This will launch the Visual Studio Installer, which will bring up a
dialog showing the available Visual Studio Build Tools workloads.
Check the C++ build tools workload and select Install.
Note: You can use the C++ toolset from Visual Studio Build Tools along
with Visual Studio Code to compile, build, and verify any C++ codebase
as long as you also have a valid Visual Studio license (either
Community, Pro, or Enterprise) that you are actively using to develop
that C++ codebase.
As what stated in visual c++ 2015 tools for windows desktop
Mount your VS2015.iso
You can find all packages at your mounted location E:\packages | G:\packages
Navigate to Control Panel.
Right-Click at your VS2015 and choose change-modify
Check the Visual C++ boxes as stated in the link.
Click on Modify.
If installer fail to update, copy the mounted directory location and paste on it.
Click Retry button.
On March 21, 2022, the best I could figure out was to find the "Visual Studio Community" free download (required logging in with Microsoft account). There was no longer any "just give me the damn Build Tools" concept, but there is the promise that you just download an installer and then pick. So I downloaded the installer and ran it.
Of course, none of the top-level options are suitable for "just give me the damn Build Tools", so I pick the "Individual Components" option. This supplies an incredibly large list of things I don't want, but buried within it I find "MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)" which looks hopeful. I check that box and I'm informed they will give me also "Visual Studio code editor".
I'm sternly warned that I'm installing "without workloads", which seems to be some additional crap that the "Visual Studio core editor" I'm never going to use wants. I decline the additional bloatware. Some gigabytes later, it says I'm "Done installing" but warns "We recommend rebooting soon to clean up any remaining files."
After decades of (re-)writing scripts to locate the Microsoft compiler, I bow to Microsoft's superior ability to keep breaking any easy method of automating this process. Whenever I install the Microsoft compiler on a system, I manually set a system-wide environment variable that points to the Microsoft batch file for setting shell environment variables for the tools. Today's machine is a no-license (hey, Microsoft sucks the same way, just not as much!) Windows 10, and that is <Winkey>-x | System | Advanced System settings | Environment Variables
I create a variable called RLBVCVARS and set it to (in this particular case) c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat My portable Windows dev environment keeps an alias that points to that so, I can mostly pretend Microsoft doesn't constantly introduce breaking changes to their installation schemes. I think you have to reboot for a "system" environment variable to take effect, but hey, Microsoft wants you to reboot after installing anything anyway, so no biggy.
First compile says can't find "io.h". Back to the installer. Let's try adding "Windows 10 SDK" (3 versions to choose from!). A GB or so later, I have an io.h and can build my current project. Onward and upward.