【问题标题】:Visual Studio 2017 Compile DirectX8Visual Studio 2017 编译 DirectX8
【发布时间】:2018-04-20 06:23:30
【问题描述】:

我正在处理一个使用 DirectX 8 的旧项目,我想知道是否有办法让 Visual Studio 2017 在仍然使用 DirectX8 的同时编译代码。

Windows SDK = 10.0.16299.0

工具集 = msvc141

我使用现代外观的 MFC 应用程序作为示例项目,但它可能与它无关,因为它仅在我包含 D3DX8.h 时发生,例如,我在 DirectX 端遇到很多语法错误。

我想知道是否有一种方法可以在我不必继续使用 Visual C++ 6.0 的情况下在 directx 8 上工作。

1>c:\mmorpg\directx\dx3d8\dxf\dxsdk\include\d3d8types.h(155): error C2011: '_D3DLIGHTTYPE': 'enum' type redefinition
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\shared\d3d9types.h(180): note: see declaration of '_D3DLIGHTTYPE'
1>c:\mmorpg\directx\dx3d8\dxf\dxsdk\include\d3d8types.h(189): error C2011: '_D3DSHADEMODE': 'enum' type redefinition
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\shared\d3d9types.h(214): note: see declaration of '_D3DSHADEMODE'
1>c:\mmorpg\directx\dx3d8\dxf\dxsdk\include\d3d8types.h(196): error C2011: '_D3DFILLMODE': 'enum' type redefinition
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\shared\d3d9types.h(221): note: see declaration of '_D3DFILLMODE'
1>c:\mmorpg\directx\dx3d8\dxf\dxsdk\include\d3d8types.h(208): error C2011: '_D3DBLEND': 'enum' type redefinition
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\shared\d3d9types.h(228): note: see declaration of '_D3DBLEND'
1>c:\mmorpg\directx\dx3d8\dxf\dxsdk\include\d3d8types.h(225): error C2011: '_D3DBLENDOP': 'enum' type redefinition
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\shared\d3d9types.h(255): note: see declaration of '_D3DBLENDOP'
1>c:\mmorpg\directx\dx3d8\dxf\dxsdk\include\d3d8types.h(234): error C2011: '_D3DTEXTUREADDRESS': 'enum' type redefinition
1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\shared\d3d9types.h(264): note: see declaration of '_D3DTEXTUREADDRESS'

【问题讨论】:

    标签: c++ mfc directx


    【解决方案1】:

    Windows SDK 不支持 DirectX 8 开发。由于 DirectX 第一次成为“操作系统的一部分”是 DirectX 9.0c 和 Windows XP Service Pack 2,Windows SDK 只具有 Direct3D 9 或更高版本的标头。

    上一个支持 DirectX 8 的旧版 DirectX SDK 是 2007 年 8 月(DirectX SDK 的生命周期结束版本是2010 年 6 月)。那是在 Windows SDK 6.0 中使用 VS 2005 / VS 2008。

    将旧版 DirectX SDK 与 Windows SDK 混合肯定会遇到挑战。 MSDN 上有使用 2010 年 6 月版本的说明,但正如我所指出的,不包括 Direct3D 8。

    DirectX SDKs of a certain ageA Brief History of Windows SDKs

    【讨论】:

    • 感谢您提供详细信息!这现在更有意义了。是否有可能创建一个 Windows XP 机器并在那里使用 Visual Studio,这样我就可以在那里继续开发而不用担心 Windows 环境?或者你能建议我在我的情况下可以做什么?
    【解决方案2】:

    从错误行: c:\mmorpg\directx\dx3d8\dxf\dxsdk\include\d3d8types.h(155): error C2011: '_D3DLIGHTTYPE': 'enum' type redefinition 1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\shared\d3d9types.h(180): note: see declaration of '_D3DLIGHTTYPE'

    => 您显然包含了两个版本的 directX 标头 d3d8types.hd3d9types.h ,引用完全相同的符号。 我认为应该只包括其中之一。

    要跟踪导致 d3d9types.h 文件包含的原因,在 Visual Studio 中,您可以激活 showIncludes 编译器选项:

    Show includes compiler option

    【讨论】:

    • 那么我应该在 Windows SDK d3d9types.h 中添加这个吗? #ifndef d3d9TYPES_H || D3D8TYPES_H #define d3d9TYPES_H
    • 您不应该接触 directX 标头,但要了解您之前已包含 d3d9types.h 的原因。您可以使用此选项查看包含树 msdn.microsoft.com/en-us/library/hdkef6tk.aspx
    • 我看到它首先包含 windows SDK,然后是 directx,所以我尝试将 directx 包含在 windows SDK 之前,然后我在C2146 - syntax error : missing ';' before identifier 'PVOID64' 的 winnt.h 中再次收到此错误我在stackoverflow的不同主题中看到,如果出现错误,应该最后包含directx。
    • 这个答案毫无帮助。它既没有确定核心问题,也没有提出解决方案。
    • 这仍然没有确定核心问题。正如 Chuck Walbourn 的回答中所解释的,DirectX 现在是 Windows SDK 的一部分。 OP 正在使用包含 DirectX 的 Windows SDK,同时尝试引用专用的 DirectX SDK。没有理由进一步诊断该问题。这问题,Chuck Walbourn 的回答还提供了可能有助于解决问题的文档链接。这个答案仍然没有帮助。
    猜你喜欢
    • 2018-12-08
    • 2017-08-28
    • 1970-01-01
    • 1970-01-01
    • 2017-07-30
    • 2018-05-26
    • 1970-01-01
    • 1970-01-01
    • 2019-04-01
    相关资源
    最近更新 更多