DirectX 11 和 g++ 编译错误

卡尔

您好,我实际上是通过本教程学习 DirectX 11:http : //www.rastertek.com/dx11tut03.html

第一部分

我的代码(问题来自哪里):d3dclass.h:

//Linking
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "d3dx11.lib")
#pragma comment(lib, "d3dx10.lib")

//Include
#include <dxgi.h>
#include <d3dcommon.h>
#include <d3d11.h>
#include <d3dx10math.h>

我都喜欢教程,唯一的区别是我用 g++ 编译它,通过这个命令:

g++ -mwindows WinMain.cpp systemclass.cpp inputclass.cpp graphicsclass.cpp d3dclass.cpp -o Prog.exe -I "D:\Programme File\DirectX SDK\Include" 2> log.txt

但在输出文件中,我有大量错误。这是日志.txt:

https://drive.google.com/open?id=1XUlcAFUyRcLIvdKbe0FkLVjkvwxpOmEv

总结一下日志,dxgi.h中没有声明__in之类的东西很多,但是这个头文件来自DirectX11库;

第二部分

通过添加以下内容,我找到了解决很多问题(第一部分)的方法:

#define __in
#define __out
#define __inout
#define __in_bcount(x)
#define __out_bcount(x)
#define __in_ecount(x)
#define __out_ecount(x)
#define __in_ecount_opt(x)
#define __out_ecount_opt(x)
#define __in_bcount_opt(x)
#define __out_bcount_opt(x)
#define __in_opt
#define __inout_opt
#define __out_opt
#define __out_ecount_part_opt(x,y)
#define __deref_out
#define __deref_out_opt
#define __RPC__deref_out

但仍然存在一个主要问题,这是错误输出:

 D:\Programme File\DirectX SDK\Include/d3dx10core.h:345:13: error: expected ';' at end of member declaration
     HRESULT WINAPI_INLINE GetDesc(D3DX10_FONT_DESCA *pDesc) { return GetDescA(pDesc); }

它来自 WINAPI_INLINE(这是在 DirectX 标头中)

我怎样才能解决这个问题?请。

查克·沃尔伯恩

我没有任何使用 g++ 的经验,但我可以在这里提供一些细节方面的帮助。要使用 g++,您需要安装 Windows SDK并将其配置为包含正确的路径。旧版 DirectX SDK 需要 Windows SDK,并且不是完全独立的。

请注意,旧版 DirectX SDK 和 Windows SDK 并未声称与 GCC 工具链兼容。

__in__out等宏被称为“SAL注释”,他们是有改善静态代码分析的内部都在微软的质量和使用Visual C ++的时候/analyze开关。在其他情况下,它们被定义为“空白”,因此它们只是从代码中删除。宏在 Windows SDK 中定义。您可以尝试显式地执行 a#include <sal.h>和/或#include <specstrings.h>在包含dxgi.h.

要记住的另一件事是,传统的DirectX SDK本身过时与一起D3DX9D3DX10D3DX1工具库。因此,如果您使用的是 Windows 8.0、8.1 或 10 SDK,则可以在不使用 Direct3D 11 的情况下对其进行编码——请参阅Living without D3DX如果您确实想继续使用那些较旧的帮助程序——有些过时的 rastertek 教程假设——,您可以这样做,但您需要确保在 Windows SDK 包含/lib 路径之后搜索 DirectX SDK 包含和lib 路径.

如果您使用的是 Visual C++(顺便说一句,它有一个免费的社区版),那么您可能会过得更轻松。您可能还想查看DirectX 工具包教程

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章