Cannot open include file: 'ntddk.h'

 ̄綄美尐妖づ 提交于 2019-12-19 05:16:34

问题


I'm been trying to get into driver development (queue the "don't do that") I have been looking at this msdn page and after installing the WDK (Windows Driver Kit) 10 I am still unable to compile the example that they use on that page.

I have looked at other SO questions but I am unable to find the installed directory of the WDK. When I attempt to run the setup I am greeted by this:

How can I solve this?


回答1:


You need to add WDK headers path to your vcxproj include directories:
vcxproj properties -> C/C++ -> General -> Additional Include Directories

C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\km\

P.S.: Make sure you install SDK 10 together with WDK 10.
P.P.S: Without SDK you will get Cannot open include file: 'ntdef.h' error




回答2:


Rule of thumb

When you need to build with the latest (or specific) version of WDK, check that corresponding version of Win SDK is installed.

Suspected cause

In process of debugging the issue it appeared that (because of SDK version) build process was setting $(LatestTargetPlatformVersion) to 10.0.10586. While the installed WDK provides needed versions of build files only for 10.0.14393 version. Looks like this is somewhat intended behavior.

My case

In my case it was due to different versions of Win SDK and WDK. I had SDK 10.0.10586 and WDK 10.0.14393. Installing SDK 10.0.14393 solved the issue for me.

Side note

Win SDK gets installed with default layout of VS2015, but for some reason it doesn't get updates in process of VS updates.




回答3:


There is a macros $(DDK_INC_PATH) that can be added to include directories of your project (vcxproj properties -> VC++ Directories -> Include Directories)




回答4:


Solved it by selecting a different "Windows SDK Version" in Visual Studio under Project Properties -> General.

In the directory C:\Program Files (x86)\Windows Kits\10\Include I have 5 folders with Windows SDKs. The newest (10.0.17763.0) did not have a km subfolder. After changing the Windows SDK Version from 10.0.17763.0 to 10.0.17134.0 in Visual Studio the ntddk.h header was found.



来源:https://stackoverflow.com/questions/35777922/cannot-open-include-file-ntddk-h

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!