DirectX 11和G 编译错误

DirectX 11 and g++ compile error

本文关键字:编译 错误 DirectX      更新时间:2023-10-16

你好,我实际上在本教程中学习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: program file directx sdk include

但是在输出文件中,我有很大的错误。这是log.txt:

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

要概括日志,有很多诸如__in之类的东西在dxgi.h中尚未声明,但是此标头来自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 FileDirectX SDKInclude/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注释",它们在那里可以提高Microsoft内部和使用Visual C 的/analyze开关时的静态代码分析质量。在其他情况下,它们被定义为"空白",因此它们只是从代码中删除。宏位于Windows SDK中定义。您可以在包含dxgi.h版本之前尝试明确执行#include <sal.h>和/或#include <specstrings.h>

要记住的另一件事是,传统DirectX SDK本身与D3DX9D3DX10D3DX1实用程序库一起弃用。因此,如果您使用的是Windows 8.0、8.1或10 SDK,则无需使用它即可编码Direct3d 11,请参阅没有D3DX的生活。如果您确实想继续使用那些较旧的助手 - 那些有些过时的rastertek教程假设 - 您可以这样做,但是您需要确保DirectX SDK Include Incluction include and lib Paths Windows SDK包括/lib路径。

如果您使用的是Visual C (BTW具有免费的社区版本),那么您可能会有更轻松的时间。您可能还想查看DirectX工具套件教程。