-->

I can't configure include paths in VSCode for

2019-08-26 10:29发布

问题:

[EDIT] This is about a vsCode project not a visual studio project (clarified here because it is not obvious)

Did anyone managed to build an app that includes d3d12.h and links successfully with the D3D lib. I know it lives in C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um But when I add it to the include paths of c_cpp_properties.json I get this error:

cannot open source file "kernelspecs.h" (dependency of "d3d12.h")

Which makes sense.

This page mentions a DXSDK_DIR environment var but it is not defined on my computer although I have "Windows 10 SDK software" and "VS community 2017" installed. https://docs.microsoft.com/en-us/windows/desktop/direct3d12/directx-12-programming-environment-set-up

I have the impression it is impossible to build a D3D12 App with VSCode right now. Am I wrong ?

[Edit] Okay so I added all four include paths in this way (I am using g++):

 "command": "${env:Cygwin64BinPath}/g++.exe",
        "args": 
        [
            "-g", 
            "-o", "MassiveSteering", 
            "*.cpp", 
            "-D_DEBUG",
            "-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/shared",
            "-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/um",
            "-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/winrt",
            "-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/cppwinrt"
        ],

But I get the following error:

Executing task: C:\cygwin64\bin/g++.exe -g -o MassiveSteering *.cpp -D_DEBUG '-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/shared' '-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/um' '-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/winrt' '-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/cppwinrt' <

In file included from C:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/shared/minwindef.h:182:0,

from C:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/shared/windef.h:24,

from C:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/um/windows.h:171,

from main.cpp:7: C:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/um/winnt.h:154:2: error: #error "No Target Architecture"

The only thing in my only cpp is :

#define UNICODE // Necessary to use long chars in windows 
#define _UNICODE

#define WIN32_LEAN_AND_MEAN

// include the basic windows header file
#include <windows.h>

回答1:

The standard Visual Studio integration has all of the following four INCLUDE paths:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\winrt
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\cppwinrt

If you just used um, that's why it failed.

For LIB you need:

C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17134.0\ucrt\<arch>
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17134.0\um\<arch>

DXSDK_DIR environment variable is an outdated reference to the Beta version of DirectX 12 SDK which shouldn't be there anymore because it doesn't exist outside of the Beta. The DirectX 12 headers & libs are part of the Windows 10 SDK.

The D3DX12.H utility header is not in any SDK, you just get it from GitHub.

You may also want to check out the DirectX Tool Kit for DirectX 12.