7

We're moving to Visual Studio 2017 and VS2017 prompts us to retarget the projects for 2 things: Windows SDK Version and Platform Toolset.

Currently our application can run on older Windows versions (at least to Server 2003, possibly older), and we need to retain the same (I know they're not supported anymore, but that's the customer's requirement).

Assuming that our code (which is all C++ in case it makes a difference) does not use any APIs which are only available on newer versions of Windows, will re-targeting to a newer version of the Windows SDK restrict or limit the versions of Windows that our app will run on?

And while on the subject, will re-targeting to a newer version of the Windows SDK have any pros or cons (ex. performance) (again, assuming we don't use any of the new APIs that are only available on newer Windows)?

codesniffer
  • 1,033
  • 9
  • 22
  • no, SDK not restrict versions of Windows where your app will run. if you say will be use only api calls which exist on xp (i mean static linked) - your program can run on xp (need not forget set minimum supported windows version in linker [/SUBSYSTEM](https://msdn.microsoft.com/en-us/library/aa278557(v=vs.60).aspx) option only) – RbMm Jan 11 '18 at 20:45
  • about pros or cons (ex. performance) - new SDK headers usually more big, because containing almost all what exist in old headers + some new definitions, api, etc. but visible different in compile or link time think you not found. so if you want design some code for newest windows versions, use newest api - you need most resent sdk/wdk. if you want build only for old windows versions - you in general can use any version. may be you will be need some little changes when migrate to new sdk version, but this not restrict you to run code say on xp – RbMm Jan 11 '18 at 20:51
  • It will be restricted by platform toolset you use. In order to run applications on Windows Xp you will need to install v141_xp toolset. Seet [How to target Windows XP in Microsoft Visual Studio C++](https://stackoverflow.com/questions/35664861/how-to-target-windows-xp-in-microsoft-visual-studio-c). Retargeting pros: better standard conformance, support for newer intrinsics, better code analysis; cons: worse codegen, splitted runtime with larger redist. – user7860670 Jan 11 '18 at 20:54
  • 1
    Version targeting of the Windows SDK is done by defining compile time macros see: https://msdn.microsoft.com/en-us/library/6sehtctf.aspx – Richard Critten Jan 11 '18 at 20:57
  • @VTT: Thanks for the tip about Platform Toolset. I don't need to support XP, but if I use the standard v141 toolset from VS2017, will the app run on Win7/Server2008+ ? In other words, is the "XP" special toolset only needed in order to run on XP, or are other toolsets needed for other older versions like Server 2003, 2008, etc? – codesniffer Jan 11 '18 at 21:02
  • I think Server 2003 corresponds to windows XP. But building for Windows 7 should work fine (at least it worked not so long ago). – user7860670 Jan 11 '18 at 21:15
  • @VTT: you listed "worse codegen" as a con of retargeting. Can you elaborate on this? Any references I can read on it? – codesniffer Jan 11 '18 at 21:28
  • With increasing language syntax complexity and growing codebases compilers seem to be more and more tailored towards fast compilation. Even minimum analysis possible with weak type system of c/c++ is often omitted. From my experience switching to newer compiler **always** leads to larger and slower code (based on chain of migration gcc 4.1 ... gcc 6.3 and vs2008 ... vs2017). Recent VC++ compilers went under major refactoring (as described in VS team blog) and "security enchantments" so in some situations even use of recent c++ features (such as move and rvo) does not allow to keep performance. – user7860670 Jan 11 '18 at 21:56

2 Answers2

8

No, using a newer SDK allows use of newer funcntionality but it does not require doing so. So long as you are careful to only use functionality that is present on the version of windows you are interested in your program will continue to work. You will, however, likely need to install the vs2017 runtime on the client systems.

SoronelHaetir
  • 14,104
  • 1
  • 12
  • 23
  • 1
    Confirmed build from VS2017 will run at least back to Win7, provided Microsoft Visual C++ Runtime 2017 is installed/available on the system to run. This is available in the Microsoft Visual C++ Redistributable Packages for Visual Studio 2017 which is available for downloaded free from https://www.visualstudio.com/downloads/ . 64-bit direct link: https://go.microsoft.com/fwlink/?LinkId=746572 – codesniffer Jan 12 '18 at 23:49
  • And you can change the compiler settings (in particular the Platform Toolset on the General tab of the project settings) and it should work back to XP. – SoronelHaetir Jan 13 '18 at 06:54
1

You will need the VC++ runtime for the development kit that you are building from. Statically linking this library will remove this requirement, as the runtime is embedded in your binary.

N00byEdge
  • 1,106
  • 7
  • 18