DirectX 11 和 g++ 编译错误
DirectX 11 and g++ compile error
您好,我实际上是通过本教程学习 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
但是在输出文件中,我有大量的错误。这是 log.txt:
https://drive.google.com/open?id=1XUlcAFUyRcLIvdKbe0FkLVjkvwxpOmEv
总结日志有很多像__in这样的东西没有在dxgi.h中声明,但是这个header来自DirectX11 Library;
第二部分
我找到了通过添加这个来解决我的很多问题(第一部分)的方法:
#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 header)
我该如何解决这个问题?请
我没有任何使用 g++ 的经验,但我可以在这里提供一些帮助。要使用 g++,您需要 install the Windows SDK 并将其配置为包含正确的路径。旧版 DirectX SDK 需要 Windows SDK,并且不是完全独立的。
Note that the legacy DirectX SDK and the Windows SDK don't claim to be compatible with the GCC toolchain.
__in
、__out
等宏称为 "SAL annotations",它们用于提高 Microsoft 内部和使用 Visual C++ 的静态代码分析的质量 /analyze
切换。它们在其他情况下被定义为 'blank',因此它们只是从代码中删除。宏在 Windows SDK 中定义。在包含 dxgi.h
.
版本之前,您可以尝试明确地执行 #include <sal.h>
and/or #include <specstrings.h>
另一件要记住的事情是旧版 DirectX SDK 本身是 deprecated along with the D3DX9
, D3DX10
, and D3DX1
utility libraries. 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。如果您确实想继续使用那些较旧的助手——有些过时的 rastertek 教程假设——,您可以这样做,但您需要确保搜索 DirectX SDK 包含和 lib 路径 after Windows 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. You might also want to see the DirectX Tool Kit tutorials.
您好,我实际上是通过本教程学习 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
但是在输出文件中,我有大量的错误。这是 log.txt:
https://drive.google.com/open?id=1XUlcAFUyRcLIvdKbe0FkLVjkvwxpOmEv
总结日志有很多像__in这样的东西没有在dxgi.h中声明,但是这个header来自DirectX11 Library;
第二部分
我找到了通过添加这个来解决我的很多问题(第一部分)的方法:
#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 header)
我该如何解决这个问题?请
我没有任何使用 g++ 的经验,但我可以在这里提供一些帮助。要使用 g++,您需要 install the Windows SDK 并将其配置为包含正确的路径。旧版 DirectX SDK 需要 Windows SDK,并且不是完全独立的。
Note that the legacy DirectX SDK and the Windows SDK don't claim to be compatible with the GCC toolchain.
__in
、__out
等宏称为 "SAL annotations",它们用于提高 Microsoft 内部和使用 Visual C++ 的静态代码分析的质量 /analyze
切换。它们在其他情况下被定义为 'blank',因此它们只是从代码中删除。宏在 Windows SDK 中定义。在包含 dxgi.h
.
#include <sal.h>
and/or #include <specstrings.h>
另一件要记住的事情是旧版 DirectX SDK 本身是 deprecated along with the D3DX9
, D3DX10
, and D3DX1
utility libraries. 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。如果您确实想继续使用那些较旧的助手——有些过时的 rastertek 教程假设——,您可以这样做,但您需要确保搜索 DirectX SDK 包含和 lib 路径 after Windows 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. You might also want to see the DirectX Tool Kit tutorials.