Can I use older minor version of C++ compiler in VS2019? - c++

There are some bugs introduced in 16.7 that affect me, and I would like to use 16.6.
Most of the questions I found refer to using VS2017 compiler, I want to use VS 2019 compiler, just an older version.
Best I found in official docs is to remove VS and reinstall, but I would like to avoid that.

I found solution of such problem for myself in following way.
You should locate MSVC build tools of chosen version in your folder like "Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC XX.YY.ZZZZ. If you just upgraded your VS it didn't remove old build tools (I hope). If it did or you just installed newer versions you can use VS Installer to add/download MSVC Build Tools of one of previous version.
You should change links to VCTools of previous version for Toolset v142 (that is 2019). To do his you can change text files located at something like "2019\Enterprise\VC\Auxiliary\Build". Files of our interest are "Microsoft.VCToolsVersion.v142.default.txt" and "Microsoft.VCToolsVersion.v142.default.props".
That simple files just contains names of MSVC Tool version to use for Toolset v142
These changes will affect building of all you projects using toolset v142 (that is VC2019 Compiler)

I am sorry that VS does not currently support the ability to roll back a Visual Studio Update, you can only follow the method in the link. Luckily, Microsoft have already understood this issue and rolling back updates is certainly in their backlog. You could vote on this issue and express your demands.

Related

How do I obtain Microsoft's C++ compiler and standard library (and just that)?

I want to try compiling some C++ code with Microsoft's C++ compiler, and using their standard C++ library. But, I would really rather not install their Visual Studio IDE. I have in the past installed "the whole enchilada", and the compiler naturally worked, but I recall it was really huge.
Now, I know Microsoft has a gratis Community Edition of its IDE, which includes its compiler, so I should be fine license-wise. Some browsing led me to this download site: https://visualstudio.microsoft.com/downloads/, but I only seem to be offered variants of Visual Studio, the IDE. If I search around for "Microsoft C++ Compiler", I either find Visual Studio sites, or downloads which seem more relevant scope-wise but are out of date, like this. Then there are Windows SDK's, I hope I don't have to get those, or do I? I also remember there are all sorts of "redistributable" packages you can download, and maybe other "build tools" packages - perhaps the compiler is really just a "build tool"?
If I do try the Visual Studio Community Edition installer - I ostensibly get the option to select which components I want to install. But, when I choose no components other than the "core C++ desktop features" (which probably means no compiler either), it wants to install 1.9 GB of data... and adding the MSVC v142 build tools bumps me up to 3.86 GB. Yikes!
Bottom line: What should I do so as to install just the MSVC compiler and the standard library (and the minimum possible set of other stuff I don't need alongside them)?
Note: This question is closely related to mine, but is not specifically about downloading and installing just the compiler and standard library. Hence one of the answers says: Download MSVS, but just run the compiler. The highest-scored answer ostensibly offers a Visual-Studio-independent download! ... except when you follow the link, you're immediately told the "build tools" are now part of Visual Studio 2017. IIUC anyway.
Visual Studio Build Tools is indeed the correct version. I have it installed on our build server.
Yes, it's called "Visual Studio" like the other products in the line, but that doesn't mean it comes with an IDE. It does come with the Visual Studio Installer, so you can select the C++ compiler.
The basic install is vs_buildtools.exe –quiet –add Microsoft.VisualStudio.Workload.VCTools. This is a C++ "workload" that's not available with the Visual Studio Community, where you'd use Microsoft.VisualStudio.Workload.NativeDesktop instead.

How can I avoid an error loading Microsoft.VisualStudio.Threading in Visual Studio 2017

I have made a log of updates to my Visual Studio package in a version which only targets Visual Studio 2019. One change that I started using the NuGet package Microsoft.VisualStudio.SDK, version 16.0.202 and removed a lot of separate references to DLLs.
Now I have ported the latest version of my package back to Visual Studio 2017 and downgraded several NuGet packages (for example Microsoft.CodeAnalysis) to older versions.
I have downgraded Microsoft.VisualStudio.SDK to version 15.9.3, which is the oldest available version.
Initially, this seemed to work fine on several systems. However, on one system my package is not loaded and a message is written to the Activity Log, something like
Could not load file or assembly 'Microsoft.VisualStudio.Threading, Version=15.8.0.0
(The message is actually in German, but that is the equivalent message in English.)
I can see two possible solutions:
[1]
Throw out Microsoft.VisualStudio.SDK and go back to referencing lots of separate DLLs.
I would prefer not to do that.
[2]
Increase the minimum required version number of Visual Studio.
Using Microsoft.VisualStudio.SDK version 15.9.3, would I have to set the minimum version of Visual Studio to 15.9.3?
(That would be restrictive, but better than a package that doesn't load.)
Increasing the minimum required VS version is necessary.
1.For packageReference format, if one project references the Microsoft.VisualStudio.SDK package, this project actually depends on the nuget packages the Microsoft.VisualStudio.SDK depends on. We call them nuget package dependencies.
2.And for Microsoft.VisualStudio.SDK package with version 15.9.3, it also depends on Microsoft.VisualStudio.Threading package.(At least 15.8.132, by default nuget will download the 15.8.132)
So your extension project actually depends on Microsoft.VisualStudio.Threading.dll 15.8.0.0.
3.And for Microsoft.VisualStudio.Threading.dll under path C:\Program Files (x86)\Microsoft Visual Studio\2017\xxx\Common7\IDE\PrivateAssemblies, for VS2017-15.9.16, its version is 15.8.0.0. For VS2017-15.0.0, its version is 15.0.0.0.
Then if I have a VS2017-15.6.x, I could have the Microsoft.VisualStudio.Threading.dll whose version in this scope [15.0.0.0,15.8.0.0). If we install the extension which depends on that assembly with version 15.8.0.0 into an older vs version than 15.8.x, we'll meet similar issue.
I can see two possible solutions
I think your user could be in a similar situation with an older vs version. And if he updates vs to latest vs2017-15.9.17, this issue will go away. And yes, if you using Microsoft.VisualStudio.SDK version 15.9.3, please set minimum version of Visual Studio to 15.9.3.
You can check the dependencies there:
This package also depends on packages with 15.9.2x, even 15.9.3 versions. To avoid meeting similar issues like Could not load file or assembly 'xxx, Version=15.9.0.0, increasing the minimal requirement to make VS version consistent with the VS SDK version is recommended. (In VS with version 15.9.0, we may not meet issue like can't load xxx with 15.8.0.0, but we may encounter issue like can't load xxx with 15.9.2.0)
Hope it helps :)
Using VS 2022
I have mange to solve this issue by install/update those nuggets
Image showing the needed nuggets

Visual Studio 2015, Using 2015 Compiler

I have a simple question in which I think the answer is no as I can only find back wards compatibility with Visual Studio.
I was wondering can VS2015 use the latest C++ compiler offered with VS2015? I am running into issues with things like to_string not being defined, while I have a work around for all my issues I would like to code with simple function calls rather than use work arounds.
If anyone knows how to do this or can show me a trick for it please let me know!
PS I saw the http://daffodil.codeplex.com/ and I see it only lets me set compiler settings for older versions of VS.
You can set the Platform Toolset to Visual Studio 2015. Bring up the properties for your project, and on the General page you can specify the Platform Toolset. If VS2015 isn't listed you installed the IDE but not the C++ compiler, or something got messed up in your install.

How to compile C++ for Windows with clang in Visual Studio 2015

As far as I understand, Visual Studio 2015 is shipped with clang. First I though this was only for Android and iOS apps, but according to this article it should also be possible to use the clang++ frontend for Windows programs. However, I can't find the according option.
So could you please explain to me, how I can change the used compiler to clang in a c++ project (in VS2015 RC Community Edition).
Starting with VS2015 Update 1 you can install the "Clang with Microsoft CodeGen" template via the New Project window, browse to Installed -> Templates -> Visual C++ -> Cross Platform.
You will then be able to choose the Clang 3.7 with Microsoft CodeGen v140_clang_3_7 Platform Toolset in the properties page of any Windows C++ project.
Clang has a completely different set of command-line options which it recognizes, so when using the v140_clang_3_7 toolset, the project properties must be using Clang-compatible options, which can be recognized as starting with - instead of /. For example, Debug Information Format property set to "Full Debug Information (DWARF2) (-g2 -gdwarf-2)", and Enable C++ Exceptions property set to "Yes (-fexceptions)".
There's more information in this blog post.
As far as I understand it both Clang and GCC are shipped with the Android and iOS crossplatform SDKs/tools for Visual Studio 2015.
From what I've seen it only allows me to choose those while having one of those crossplatform projects.
Using the template project for a GLES C++ application you get the following options:
While for a Windows C++ application you get the dialog below where you can see that Windows target platform is grayed out and read-only, meaning you probably have a set of toolkits for each target platform, but you simply cannot change it, at least for now.
Have no idea how you turn a normal VS project into crossplatform though, and it's likely that you can only target Android or iOS out of the box using 3rd party compilers.
It may be possible, though, to install Clang as another toolkit in the same way the XP toolkits are. So perhaps it's just a matter of someone fiddling with it and making it available as it is already installed.
Caveat: This answer is pre-VS2015 update 1 which didn't have the "Clang with Microsoft CodeGen" option.
After reading through the linked post and especially the comments again, I came to understand, that this is not a feature shipped with VS2015 RC but a possible future feature that might e.g. be shipped in a SP or (more likely) with the next version of VS.
As mentioned by sjdowling, the closest thing you can do at the moment (October 2015, clang 3.7) is to download and install llvm for windows. This should give you a LLVM-vs2014 platform toolset option. For me it works for simple test programs, but apparently this version of "clang-vs" seems to not yet support exceptions. However, according to these notes, that problem should be mostly solved for clang 3.8.
While the above solutions work they require that you have installed clang which is off by default in the visual studio 2015 installation. The accepted answer does show how to install it, though the next page will ask you to close visual studio which you are running the new project from.
If anyone is wondering how to install clang because it does not show up in their list here is another solution:
Control Panel->Programs->Programs and Features.
Right click on “Microsoft Visual Studio Enterprise 2015” (or
“Microsoft Visual
Studio 15 Preview” if you have the preview of the next version of
Visual Studio installed)
Click “Change”
Click “Modify”
Select “Clang with Microsoft CodeGen” – The March 2016 release.
https://blogs.msdn.microsoft.com/vcblog/2016/03/31/clang-with-microsoft-codegen-march-2016-released/

Linking against older version of runtime with newer version of MSVC?

I own VS 2008 Pro, and would like to do compatibility testing with VS 2005's runtime MSVCRT80, but I do not want to buy it just for that. Is there a way to link against MSVCRT80 without getting VS 2005?
Thanks
Official support for native multi-targeting didn't appear until Visual Studio 2010, which allows you to select either v100 or v90 as your "Platform Toolset". There is no such feature in Visual Studio 2008.
There is a discussion here on how one can achieve the same effect in Visual Studio 2008, but it appears you need to have VS 2005 installed on your computer as well in order for this to work. It isn't going to work if you just have the runtime libraries installed because you need the proper version of the compiler and linker, which you'll only have if you install VS 2005.
On that note, I'm not really sure what you mean by "compatibility testing". If you compile your app against v90 in VS 2008, it's not going to work with the older versions of the runtime. You have to compile and link against the version you want your app to use.
Finally, consider whether it's really relevant or not. Since you must include MSVCRT with your application anyway, what's the advantage of trying to link against an older version of the runtime? Just include v90 and be done with it.
Links to a still-working (as of 11 Jan 2011) Microsoft download for Visual C++ Express 2005 can be found here:
http://apdubey.blogspot.com/2009/04/microsoft-visual-studio-2005-express.html
This should let you compile against the VS2005 runtime without having to buy anything.
(in case the blogspot article goes away, the link for the .iso is http://go.microsoft.com/fwlink/?linkid=57034).