简体   繁体   English

DirectX 11和G ++编译错误

[英]DirectX 11 and g++ compile error

Hello I actually learning DirectX 11 with this tutorial: http://www.rastertek.com/dx11tut03.html 您好,我实际上是通过本教程学习DirectX 11的: http : //www.rastertek.com/dx11tut03.html

First Part 第一部分

My code (where the probleme come from): d3dclass.h: 我的代码(问题来自何处):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>

I do all like the tutorial, the only diference is I compile it with g++, trough this the command : 我确实喜欢本教程,唯一的不同是我使用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 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

but in the output file, I have a large sum of errors. 但是在输出文件中,我有很多错误。 This is the log.txt: 这是log.txt:

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

To sum up the log there is a lot of things like __in which has not been declared in the dxgi.h, but this header is from DirectX11 Library; 总结一下日志,有很多类似__in之类的东西,但尚未在dxgi.h中声明,但是此标头来自DirectX11库。

Second Part 第二部分

I found the way to fix a lot of my problem (of the first part) with adding this : 我找到了解决此问题的方法(添加了以下内容):

#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

but there still is a major problem, this is the error output : 但是仍然存在一个主要问题,这是错误输出:

 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); }

it comes from WINAPI_INLINE (this is in the DirectX header) 它来自WINAPI_INLINE(在DirectX标头中)

How can I fix this? 我怎样才能解决这个问题? please. 请。

I don't have any experience with using g++, but I can help with a few details here. 我没有使用g ++的经验,但是在这里我可以提供一些帮助。 To use g++ you need to install the Windows SDK and configure it to include the proper paths. 要使用g ++,您需要安装Windows SDK并将其配置为包括正确的路径。 The legacy DirectX SDK requires the Windows SDK and is not fully standalone. 旧版DirectX SDK需要Windows SDK,并且不是完全独立的。

Note that the legacy DirectX SDK and the Windows SDK don't claim to be compatible with the GCC toolchain. 请注意,旧版DirectX SDK和Windows SDK并不声称与GCC工具链兼容。

The __in , __out , etc. macros are called "SAL annotations" and they are there to improve the quality of static code analysis both internally at Microsoft and when using Visual C++'s /analyze switch. __in__out等宏称为“ SAL批注”,它们可以在Microsoft内部以及使用Visual C ++的/analyze开关时提高静态代码分析的质量。 They are defined as 'blank' in other cases so they just get removed from the code. 在其他情况下,它们被定义为“空白”,因此它们只会从代码中删除。 The macros are defined in the Windows SDK. 宏在Windows SDK中定义。 You can try explicitly doing a #include <sal.h> and/or #include <specstrings.h> before including a version of dxgi.h . 您可以尝试在包含dxgi.h版本之前显式地执行#include <sal.h>和/或#include <specstrings.h>

Another thing to keep in mind is that the legacy DirectX SDK itself is deprecated along with the D3DX9 , D3DX10 , and D3DX1 utility libraries. 要记住的另一件事是, 不推荐使用旧版DirectX SDK以及D3DX9D3DX10D3DX1实用程序库。 As such, if you are using the Windows 8.0, 8.1, or 10 SDK you can code Direct3D 11 without using it at all--see Living without D3DX . 因此,如果您使用的是Windows 8.0、8.1或10 SDK,则可以完全不使用Direct3D 11进行编码-请参阅《不带D3DX的生活》 If you do want to continue to use those older helpers--which the somewhat dated rastertek tutorials assume--, you can do so but you need to make sure the DirectX SDK include and lib paths are searched after the Windows SDK include/lib paths. 如果确实要继续使用那些较旧的帮助程序(有些时候过时的rastertek教程假定),可以这样做,但是需要确保在Windows SDK的include / lib路径之后搜索DirectX SDK的include和lib路径。 。

If you were using Visual C++ (which BTW has a free Community edition available), then you'd probably be having an easier time. 如果您使用的是Visual C ++(该BTW具有免费的社区版本 ),那么您可能会过得更轻松。 You might also want to see the DirectX Tool Kit tutorials . 您可能还希望查看DirectX Tool Kit教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM