Cannot open include file: 'ntddk.h'

前端 未结 6 2174
隐瞒了意图╮
隐瞒了意图╮ 2021-01-04 05:30

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 a

相关标签:
6条回答
  • 2021-01-04 05:48

    I also faced the similar problem. Below worked for me:

    Step 1: Aware of Targeted Windows Platform for which you are going to develop driver. You can check 'Windows Version' on your system by looking at Settings->System->About->Windows Specification

    Step 2: Make sure you install compatible "Windows SDK" and "WinSDK" matchingto targeted windows platform version.

    • For Windows 10, version 1903 follow https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk
    • For Previous Platforms follow https://docs.microsoft.com/en-us/windows-hardware/drivers/other-wdk-downloads

    Step 3: Verify "ntddk.h" exists at $(DDK_INC_PATH). This pre-processor macro typically evaluates to "C:\Program Files (x86)\Windows Kits\10\Include\\km". If you do not see 'km' folder then carefully follow the links mentioned in step 2 above.

    Step 4: Verify Project Properties -> Configuration Properties -> General -> Platform Toolset is using "WindowsKernelModeDriver" .

    0 讨论(0)
  • 2021-01-04 05:48

    In case you try to build on a new system, then perhaps first try to retarget the solution to that system

    If this does not work then look for the subfolder KM - mentioned in some of the above explanations and then try to retarget to that version, by changing the $(LatestTargetPlatformVersion)

    Hopefully then you should beable to build with the ntddk.h file NB! Keep in mind that this will force your solution to build to that specific platform and if you try to build on another, then you will have to manually change it again. A better solution would be to make some sort of pre-build step which takes care of missing SDK and installs it, however I do not have such a solution - any one ?

    0 讨论(0)
  • 2021-01-04 05:52

    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.

    0 讨论(0)
  • 2021-01-04 05:55

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

    0 讨论(0)
  • 2021-01-04 05:59

    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

    0 讨论(0)
  • 2021-01-04 06:01

    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.

    0 讨论(0)
提交回复
热议问题