[编辑] 这是关于 vsCode 项目而不是 Visual Studio 项目(此处澄清,因为它不明显)
是否有人设法构建了一个包含 d3d12.h 并成功链接到 D3D 库的应用程序。我知道它位于 C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um 但是当我将它添加到 c_cpp_properties.json 的包含路径中时,我收到此错误:
无法打开源文件“kernelspecs.h”(“d3d12.h”的依赖项)
这是有道理的。
此页面提到了 DXSDK_DIR 环境变量,但它没有在我的计算机上定义,尽管我安装了“Windows 10 SDK 软件”和“VS community 2017”。 https://docs.microsoft.com/en-us/windows/desktop/direct3d12/directx-12-programming-environment-set-up
我的印象是现在用 VSCode 构建一个 D3D12 应用程序是不可能的。我错了吗 ?
[编辑]好的,所以我以这种方式添加了所有四个包含路径(我使用的是 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"
],
但我收到以下错误:
执行任务: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:/程序文件 (x86)/Windows Kits/10/Include/10.0.17134.0/cppwinrt' <
在 C:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/shared/minwindef.h:182:0 包含的文件中,
来自 C:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/shared/windef.h:24,
来自 C:/Program Files (x86)/Windows Kits/10/Include/10.0.17134.0/um/windows.h:171,
来自 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"
我唯一的 cpp 中唯一的东西是:
#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>