Why does the latest WDK not support Windows 7 by default? - c++

I downloaded driver which targets Windows 7 (has option "TargetVersion" == "Windows 7" in ".vcxproj"). Also I installed Visual Studio 2022 Community, the latest SDK and DDK (for Windows 11) to compile it.
When I press "Build solution", I get error:
Windows7 is not a supported OS Version
I'm going to open file:
C:\Program Files (x86)\Windows Kits\10\build\10.0.22621.0\WindowsDriver.Common.targets
and comment the following line:
<Error Text=" '$(TargetVersion)' is not a supported OS Version"
Condition="'$(WindowsTargetPlatformVersion)' > '$(TargetPlatformVersion_CO)' and '$(TargetVersion)' !='$(LatestTargetVersion)' " />
Then trying to compile again.. and voila - everything works. Meaning driver works well for all operation systems up to Windows 10.
I do understand I'm doing wrong. So, my questions are:
Why don't Visual Studio developers let us build drivers for Windows 7 if everything works?
What is the correct way to build drivers for all operating systems, starting with Windows 7?
Added later:
I think maybe, for example, latest WDK has more API functions which are missing in Windows 7. It turns out that if we code carefully, checking all calls for compatibility, then there should be no problems with compilation.

Per this page:
To target Windows 8.1, Windows 8, and Windows 7, you will need to
install an older WDK and an older version of Visual Studio either on
the same machine or on a separate machine. For links to older kits,
see Other WDK downloads.

Question #1 - you better ask Microsoft.
Question #2 - you can install multiple SDK and WDK versions side by side. To target Windows 7, install Windows 8.1 SDK and WDK.

Related

Why do I get "Illegal Instruction" error when Building on windows10 and running on Windows7

I have a c++ program built using VS2017 on windows7.
When I run it on Windows7 or windows10 there is no problem.
If I Build the same program on Windows10 (still using VS2017) the program runs OK on Windows10 but when I try to run it on Windows7 I get an "0xC000001D: Illegal Instruction." error.
Is it even possible to run programs built in Windows10 on Windows7 ? and if so what can I do?
Thanks
The default SDKs will be different on your two VS2017 installations. Right-click the project, select "properties", then the "General" page. See Windows SDK Version.
You can install different SDK versions (and different Platform Toolsets) using the Visual Studio installer ("Modify").
You would probably need to install the v140 toolset.
Also see the response here:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/e19634d8-f635-4ed0-b8d7-45b64ccbd6fa/windows-sdk-7-in-visual-studio-2017?forum=visualstudiogeneral
...which states:
You can create a project with the default project template. After that, right click the project name under Solution Explorer and go to Configuration Properties-General, modify the 'Platform Toolset' to Windows7.1SDK, since you already installed the Windows SDK 7. Please have a look at the following note:
##To change the target platform toolset, you must have the associated version of Visual Studio or the Windows Platform SDK installed. For example, to target the Itanium platform with the Windows7.1SDK platform toolset, you must have Microsoft Windows SDK for Windows 7 and .NET Framework 4 SP1 installed
If the above not works, you can also modify the platform toolset to Visual Studio 2010 (v100), which has the same compiler like Windows SDK 7, if you have the VS 2010 and VS 2017 on the same computer

The Windows SDK version 7.0 was not found

I have a console C++ project which uses Boost and Catch using Visual Studio 2017 Community Edition. It was building fine last night and today it says,
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\Win32\PlatformToolsets\v140\Toolset.targets(34,5): error MSB8036: The Windows SDK version 7.0 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting "Retarget solution".
Specifically, what doe this means?
The Windows SDK version 7.0 was not found. Install the required version of Windows SDK
I repaired Visual Studio and that didn't work so it's not Visual Studio. I can compile other C++ projects.
Web-searches doesn't really find Windows SDK version 7.0, there is Windows SDK for Windows 7.
I'm completely baffled by this error.
I figured it out. Very silly problem.
The second line, "Windows SDK Version" had somehow gotten 7 on it.

building empty filter driver with vs 2015 and wdk 10 fails

I couldn't imagine, just how hard it can be for me to start building a sample minifilter driver using vs 2015 and wdk 10!
I've had 2013 running on my pc, then received a swapbuffer sample configured for 8.1. I simply installed WDK 8.1 from Microsoft and that's all. it compiled.
But when I tried to build a minifilter driver using wdk10 everything got hard as hell.
everything is done as this guy said in here and I am on a virtual machine running windows 10.
after installation and that and that and repairing this and that ... when I create an empty fsfilter driver project using vs sample project, build fails with this error:
"An SDK corresponding to WDK version '8.1' was not found. Please install the SDK before building."
This error refers to the file windowsDriver.common.targets in tis line:
<Error Text="An SDK corresponding to WDK version '$(TargetPlatformVersion)' was not found. Please install the SDK before building."
Condition="'$(MatchingSdkPresent)' != 'true'" />
can somebody give me a hint on how to solve this issue?!
thanks.
Windows 10 WDK requires matching SDK version to be installed. Looks like the default for the project you created is falling back to 8.1.
In the project properties, look for Configuration Properties -> General -> "Target Platform version" drop down and select the 10.0.10XXX.0 and try to build it.
If you have installed the latest version of WDK(10.0.105860.0) then make sure the corresponding SDK is installed too. You can check this in the VS installer to see if "Tools (1.2) and Windows 10 SDK (10.0.10586)" under "Universal Windows App Development Tools" is selected.
UPDATE
After much mucking about it turns out that the WDK is not enough; you also need to install the latest Windows 10 SDK which does not by default get installed or updated with Visual Studio. I thought it did, (I've got VS2015, Update 3) but clearly it doesn't. I got the latest version from https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
, retargeted my project to the latest version (at the time of writing that is 10.0.14393.0), and both the 10 year old sample and the VS wizzard generated projects now work (at least the small sample I've tried.)

Visual Studio 2015 Change target platform to windows 7

How can I change the target platform to Windows 7? All I can chose is Windows 8.1 and therefore my project does not run on Windows 7. The same project I used to compile on my old Windows 7 PC with Visual Studio 2013. And of course it worked there.
I already tried to install Windows 7 SDK but sadly this does not work since it requites Net Framework 4.0 which I can not install anymore. (Windows 10 includes 4.6?) - https://msdn.microsoft.com/en-us/en-en/library/ff770576.aspx
Thanks.
From MSDN:
Target Platform Version
[...]
To target Windows 7 or Windows Vista, use the value 8.1, since Windows SDK 8.1 is backward compatible to those platforms. In addition, you should define the appropriate value for _WIN32_WINNT in targetver.h. For Windows 7, that's 0x0601. See Modifying WINVER and _WIN32_WINNT.
To get additional target platforms (i.e. older Visual C compilers), install the respective older Visual Studio version(s) in parallel.
For instance, if you want to use Visual Studio 2017 in the GUI and want to build against VC2008 (msvc90), install Visual Studio 2008 in parallel to Visual Studio 2017. In VS2017, in the build settings, you can then select the "VC 2008" build target.
Also see:
https://poweruser.blog/visual-studio-2017-compile-against-older-visual-c-c-runtimes-372519fe1400

How set C/C++ compiler for matlab?

i've read several topics on this issue... but i'm not still able to figure out.
I've matlab 2013 and "MS Visual C++ 2012 Redistributable" both x86/x64 installed in Windows 8.
When i run "mex -setup" in matlab the following message appear:
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? y
No supported SDK or compiler was found on this computer.
For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2013a/win64.html
but the suggested file is for installing .NET 4 for windows 7, and i've windows 8. However, although i install this framework the mex -setup command still doesn't works.
It seems to still be an issue with no straightforward solution. It took me a lot of searching, reading and trial and error to get a compiler to be recognized by mex.
In a nutshell, matlab 2013 doesn't support windows 8 SDK, but windows 7 SDK does not (easily) install on windows 8.
What worked for me:
The win7 SDK doesn't install on windows 8 because more recent versions of the Visual C++ 2010 Redistributable are already installed by default on Windows 8. You have to manually (from the control panel/programs/uninstal ...) uninstall all flavors of VC++2010 redistributable (x86 and x64).
See this Microsoft article for details on how to do that.
After that I could install the SDK for win7 and got the compiler to be recognized by mex.
Note:
I run on win8 32 bits, so what worked for me may not be perfect for everybody. During my searches on the subject i also noticed that many people often stumbled on 2 other setbacks:
During the setup of win 7 SDK, .NET 4 doesn't install. => This is because .net4.5 is already shipped in windows 8. Again, uninstall .net4.5, then reinstall win7 SDK. (you can even reinstall .net4.5 if necessary after everything is done).
Once everything is installed and mex happily found the compiler, error are raised during compilation tentative about a missing ammintrin.h. You may have to install MS Visual Studio C++ 2010 express then upgrade it to SP1. In this case follow the nicely detailed instructions in this Matlab central article.
This last article linked seem to offer a complete solution, i didn't refer to it first in my answer because in some case (my case for example), only part of the setup described was necessary, so there was no point uninstalling/reinstalling a bunch of stuff. But be prepared that you may have to go though all of it ...