Linking against older version of runtime with newer version of MSVC? - c++

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).

Related

Visual Studio 2012 static library with Visual Studio 2017

I am building a static library with Visual Studio 2012 (C++), and want to give it to someone with Visual Studio 2017 so they can build their app and link against it. I will also provide the header files for them to use (but no source code that builds the library). The question is, will they be able to use the 2012 static libraries?
You cannot mix platform toolsets.
However, you can use the 2017 IDE with the 2012 platform toolset, via all project properties in your solution, if you have both versions installed.
A better solution would be to upgrade the library in question to 2017, which shouldn't be too terrible of a chore in most cases.
Absolutely not.
They will either need to build the static libraries themselves or you'll have to ship 2017 versions, and tell them comprehensively which compiler and optimisation settings were used. Therefore I would plump for the former if I were you.
Building an application binary interface (ABI for short) is extremely challenging in C++ - it's one thing that's been lost from the language's roots in C.

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/

Does VS2013 use the same C run-time as VS2012 (e.g., msvcr110)?

I've generally assumed that each version of Visual Studio was tied to a different version of the C run-time. For example: VS2005 : msvcr80.dll :: VS2008 : msvcr90.dll
One of my co-workers told me that his installer indicated that our VS2013 project had a dependency on msvcr110.dll. We both found this odd, because this is the same dependency used by VS2012.
However, MSDN backs this up:
Visual Studio 2012 C Run-Time Libraries
Visual Studio 2013 C Run-Time Libraries
Does Visual Studio 2013 indeed reuse the run-time from 2012, or am I missing something?
Edit: I forgot to mention in my original question that the Visual Studio 2013 redistributable run-time comes with a file msvcr120.dll. My confusion comes in from the fact that this file exists, yet is neither identified by our installer nor mentioned in the MSDN documentation.
Edit: After talking with my co-worker about how the dependency was being determined, the reason the installer thought our projects had a dependency on msvcr110.dll was because it was looking at an old build.
This just unfortunately coincided with the copy/paste error in the MSDN documentation regarding the versions of the run-time. I'll contact Microsoft to let them know about the documentation error. Thanks again for the help, everyone.
Note: Even if they did use the same run-time, I wouldn't assume such for any future releases. I just found this curious.
By default VS 2013 C and C++ projects will depend on msvcr120.dll (or the debug build equivalent of msvcr120d.dll).
However, it's very easy to change the dependency to msvcr110.dll by changing the 'platform toolset' to "Visual Studio 2012 (v110)" in the project settings if VS1012 is installed on the machine. Older versions of the runtimes going back to VS 2008 (v90) are supported.
I assume that the doc page for the 2013 runtime that you linked to wasn't updated due to a simple oversight.

Compile Visual Studio projects without having Visual Studio installed?

Is there a way to compile a Visual Studio 2012 project without having the VS installed? I need to compile C++ stuff for windows quite rarely and buying the product is not justified as there's no profit (community projects). In most of the cases the project and solution files will be available. If there's a way to compile the code with SDK, could you please share an example?
Thanks!
You can download visual studio express for free. Whenever you build a solution, the bin folder in your project folder will contain the compiled code.
http://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx
EDITED: (per MS website)
Visual Studio Express 2013 for Windows Desktop enables the creation of desktop apps in C#, Visual Basic, and C++, and supports Windows Presentation Foundation (WPF), Windows Forms, and Win32.
Sign in to Visual Studio within 30 days with your Microsoft account to synchronize your settings across multiple machines and register your product.
Your best bet is likely going to be using msbuild which will allow you to build a solution or project without having Visual Studio installed.
If you have the free version VC++ Express installed (and thus the compiler toolchain), you might find it more interesting to use Eclipse CDT as IDE on top. At least the newer versions (I think since Helios) support using the native MS toolchain. You can import from native
VS projects also.
Eclipse is the more powerful IDE IMHO, and will additionally support other toolchains (either cross compiling, or Windows alternatives as MinGw GCC).

How do I install the minimal facilities of Visual Studio 2008 sufficient for building C++ applications using Visual Studio 2010's multitargeting?

Dev10 has facilities for using the C++ compiler shipped in Orcas. However, I really don't need to install the full IDE -- I merely need to use Orcas' compiler because I need to support Windows 2000.
What's the simplest way of installing just the bits required to build using Orcas' toolset in Dev10?
Given your condition, I'd say just install VS2008 and use it. While it's not what you want it's the fastest path to working.
What about setting up Visual studio 2008 to work with Orcas compiler ?
I'm sorry I don't know about this very compiler, but I know it's possible to use VS2008 with a different compiler, because I tried it.
You can find plenty of doc on running VS2008 with, for example, the Windows SDK compiler or VS2010 compiler. For example that links explains that quite well : http://www.codeproject.com/Tips/105011/Using-Visual-Studio-2008-IDE-with-Visual-Cplusplus.aspx
HTH