What development environment is required to target `C++ 2008 Redistributable`? - c++

Last week I inherited a legacy unmanaged C++ application.
Unfortunately the project settings are not 100% reliable, and there is no documentation. What I do know is that the product was deployed with Microsoft Visual C++ 2008 Redistributable x86.
My question is: what combination of IDE, SDK, and Platform ToolSet would you recommend using?
Unfortunately I haven't worked with the Windows SDK before, and the Platform ToolSet option is new to me. To make matters worse, I haven't written a line of C++ code in eight years! So... any feedback you can provide would be greatly appreciated :D
KNOWNS
Client Operating System
Windows 2008 R2
C++ Redistributable
Microsoft Visual C++ 2008 Redistributable x86 is deployed in production
Integrated Development Environment (IDE)
I would prefer to use Visual Studio 2012 (we also have: Visual Studio 2008, 2010, 2012)
UNKNOWNS
Platform ToolSet
Can I use VS2012 and target the v90 platform, or is it more stable to simply use VS2008?
Windows SDK
Which version of the Windows SDK should I install on the development machine if the client is using Microsoft Visual C++ 2008 Redistributable x86 in production?

I would start by trying to get the project to compile successfully in Visual Studio 2008, since you mentioned you already have that available.
I wouldn't bother trying to install another version of the Windows SDK (one comes bundled with VS 2008) unless you can't get the project to compile successfully in an out-of-the-box install of VS 2008. If not and you do want to try installing another version of the SDK, I would opt for version 7.1, the one that targets Windows 7.
There is unlikely to be any advantage in using version 6.1 of the SDK; new versions might add new features, but they generally retain backwards compatibility with the old versions. I would not, however, install any version of the Windows 8 SDK because that might end up confusing you as the developer.
Once you get everything up and going on VS 2008, you could try switching over to VS 2012 if you'd prefer to use it. (I still can't get used to the UI, but apparently someone likes it.) As you point out in the question, the easiest way of making this work correctly would be to target "v90", which is VS 2008 (set using the Platform Toolset option). That will basically allow you to use the VS 2012 shell for editing purposes, but the VS 2008 compiler and headers for builds. You won't get any of the C++11 features introduced with VS 2012, however, because you're not using the new version of the compiler; you'll be stuck with what was supported back in VS 2008.

Related

Is it possible to target windows 10.0.14393 with C++/WinRT?

I would like to make an app for my Lumia stuck on Win 10.0.14393 (or 1609) using C++/WinRT. I've created a Blank app project with
Target platform version: 10.0.17134.0 and
Target platform min. version: 10.0.14393.
The project fails to compile with the following errors:
error C2039: 'DisconnectUnloadedObject': is not a member of 'winrt::BlankApp2::implementation::MainPageT'
error C2039: 'UnloadObject': is not a member of 'winrt::BlankApp2::implementation::MainPageT'
Is this a bug or intentional behavior? Please note, that setting any newer min. version results in successful build.
The latest version of C++/WinRT can support all versions of Windows 10, including 14393 and older versions as well.
Keep in mind that C++/WinRT is both a library and a language projection. The language projection provides access to Windows APIs targeting a given version of Windows. Each version introduces new APIs. So if you want to target a minimum version of Windows, you need to ensure that you limit yourself to the APIs available on that version of Windows. I would however recommend using the latest compiler and the latest Windows SDK as they include many bug fixes.
I suggest you use Visual Studio 2015 when targeting older C++/WinRT and Windows 10 updates. My impression is that most of those were delivered on top of Visual Studio 2015 with Visual Studio 2015 updates and Windows 10 SDK updates and C++/WinRT updates.
When using Visual Studio 2015 with C++/WinRT, you will need the latest update, Update 3. Check for updates and make sure that your copy of Visual Studio 2015 has the most recent updates. I was just using an install of Visual Studio 2015 Enterprise to recompile something that compiles fine with Visual Studio 2017 and found that I was missing tools and SDKs including for Win 10 SDK 10.0.14393 that were in the Update 3 which I had not yet installed.
You can also go to Programs and Feature from within Control Panel, look for Microsoft Visual Studio 2015 in the list and then do a right mouse click and Change which will allow you to check what is installed and change anything.
Working with C++/WinRT over the last few months I have used both the Visual Studio 2017 Community Edition and the Visual Studio 2015 Enterprise Edition.
I have seen differences when moving a solution from VS 2015 to VS 2017 that required me to review the Properties page of the solution. See also the discussion in synchronizing SDK with Windows 10 update and using WinRT with Standard C++
Working with the latest Windows 10 updates and VS 2017 works best for me because I am able to target the recent Windows 10 updates. However I have found that trying to target older Windows 10 updates with VS 2017 can be problematic.
I'm sorry that I can not be more specific. This whole area of C++/WinRT and Windows 10 updates has much more cowboy than I would like though it now seems to be settling down.
C++/WinRT is a template library that was originally an open source project on GitHub. My impression is that Microsoft has acquired it and it is now a standard product offering. I believe there was a significant rewrite of C++/WinRT at one time as the Visual Studio 2015 and then Visual Studio 2017 moved to implement more of the C++17 and proposed C++20 standards and the Technical Specifications for coroutines.
This seems to be an area still changing to some extent. However most of the changing was going on with VS 2015 and the early VS 2017 along with the SDKs. It seems to be pretty solid now with the latest updates.

How to install Visual Studio Build Tools 2010 on Visual Studio 2015 Community?

I have a project created on Visual Studio 2010. When I try to run the project on Visual Studio 2015 Community edition I get the error below,
Severity Code Description Project File Line
Error MSB8020 The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". graphics C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets 55
And when I tried to build it with Visual Studio 2015 Build Tools I encountered about 1500+ errors.
Is there any way to make the project work?
If you can't install VS2010, Windows SDK for Windows 7 contains needed compiler tools (v100), you may actually skip installing the SDK itself and install only the compiler tools, headers and libs. Please note, that the compiler included in Windows SDK is the same that VS2010 has, but VS2010 SP1 has a bit newer compiler. If you need that, you'll also need to install Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1. But be aware, that if you install these, you may have issues later if you decide to install VS2010, there are bugs in installer that requires you to install components in strict order. Also, if your code uses MFC or ATL you must install VS2010, installing Windows SDK will not be enough.
You either install VS 2010 and build your project, or better yet you upgrade your projects. The VS 2015 custom install options will let you install the v120 Platform Toolset, but not the v110 or v100 Platform Toolsets.
One major change in VS 2015 is that the C++ tools (i.e. v140) are not installed by the Typical installation option. See the Visual C++ Team Blog.
Keep in mind that Visual C++ 2010 used the C++0x Draft Standard, and Visual C++ 2015 meets the C++11 Standard with the exception of Expression SFINAE (which is partly there in Update 1), so quite a bit has changed in the intervening years including some breaking changes. Since you are jumping three major releases at once--and about 10 minor updates--, it can be a bit overwhelming especially working through all the new warnings.
Another thing to keep in mind is that Visual C++ 2010 used the Windows 7.1 SDK, while Visual C++ 2012 or later use the Windows 8.x SDK. There's been a lot of change there too particularly for DirectX development. It's particularly important for Windows desktop apps that you set the _WIN32_WINNT preprocessor define for your target platform as the Windows 8.x SDK does not default to the 'oldest supported platform' like earlier Windows SDKs did. See Using the Windows Headers
VS 2010 and the v100 toolset supports targeting Windows XP and Windows Server 2003. The v140 toolset does not support targeting Windows XP / Server 2003. You have to use v140_xp Platform Toolset instead. See this post for some notes as this means you are again using the Windows 7.1 SDK rather than the Windows 8.x SDK with the _xp toolsets.
See Breaking Changes in Visual C++ 2012, Breaking Changes in Visual C++ 2013, and Breaking Changes in Visual C++ 2015.
See also Support For C++11/14/17 Features (Modern C++), and Where is the DirectX SDK?.
If you need to build the code both with VS 2010 and with VS 2015, then you should create two projects/solution files, one for each. You may also want to read this article for some notes on writing code that can build with multiple Visual C++ toolsets, which again is particularly challenging due to the Windows SDK changes.
VS 2015 supports targeting Windows Vista SP2, Windows 7 SP1, Windows 8.0, Windows 8.1, Windows 10, and optionally Windows XP SP3. It does not support targeting Windows Vista RTM, Windows Vista SP1, or Windows 7 RTM.

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

VS 2012 - XP Issues

I installed VS 2012 Professional and the XP update as well. I built my project with v110_xp as the platform toolset on VS 2012. My project's .msi package is installing fine on Win 7 but failing on Win XP SP3. The error reported on XP SP3 is -
"The procedure entry point FlushProcessWriteBuffers could not be
located in the dynamic link library Kernel32.dll".
While the same project built from VS 2005 is installing fine on XP SP3. I am not sure what is going on VS 2012. _WIN32_WINNT is set to 0x0501. Can some one please guide as how to resolve the problem ?
Any help is highly appreciated,
Mahesh.
Yes, the C Runtime has a dependency on FlushProcessWriteBuffers(). The updated version of msvcrt110.dll and libcmtl.lib, the ones you got along with the update, no longer directly link to the function, they use GetProcAddress() to find it and limp along if it is missng. So you should never get this error.
So very high odds that you deployed the wrong version of msvcrt110.dll, an old one instead of the updated one. You can find it back in c:\windows\system32, look at the properties. Mine is version 11.00.51106.1, dated 11/5/2012. A separate installer is available for it here.
The VS2012 runtime that you are installing uses functions that are not present available in XP. See this MS article: Targeting Windows XP with C++ in Visual Studio 2012 which explains more and provides some workarounds.
Update 1 for VS2012 resolve the problem.
But Update 1 isn’t just about new Windows platforms. It also enables you to target Windows XP with native C++ applications in Visual Studio 2012.
If you are building with update 1 and still encountering problems then I suspect that you are installing an out of date runtime. You need to deploy the runtime delivered with update 1.
You can solve this by including the VC11 merge modules from your development machine(program files\common files\merge modules) in your installer. It's easier than having to run the redist exe in your installer.
If you use WIX: merge module addition
I've tested on server 03, xp64 and xp32.

Can I use build against the 2008 VS Runtime with VS 2010 and no copy of VS 2008?

It looks like using Visual Studio 2010 it is possible to build against the 2008 runtime, if you have both editions installed: Can I use Visual Studio 2010's C++ compiler with Visual Studio 2008's C++ Runtime Library?
Is it possible to do this using just the free Windows Platform SDKs and VS 2010? Just to stress - installing Visual Studio 2008 is not an option.
Background: I'd like to build a Python module for Python 2.7. I have a copy of Visual Studio 2010, but Python 2.7 (specifically the Python(x,y) distribution) is built using 2008. Rebuilding Python, or rebuilding Python(x,y) is not something I want to get into (there are various other modules I want to use as well). My module needs to link against vendor-supplied libraries built using VS 2008/2010 (I've been given both sets of libraries). I don't own a copy of Visual Studio 2008, and I really don't want to have to buy one.
This MSDN article says that although you can change the platform toolset in the IDE you still need to have the VS2008 binaries installed.
I know you said installing 2008 was not an option but perhaps you can still find the free versions in an old SDK or even the Express version on the Microsoft website.