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: 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本身与D3DX9
,D3DX10
和D3DX1
实用程序库一起弃用。因此,如果您使用的是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工具套件教程。
- std::is_base_of表示ctor编译错误
- Qt5:使用QCommandLineParser类时出现奇怪的编译错误
- 如何修复sfml c++代码编译错误
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 使用外部SDK工具链文件在VisualStudio上生成项目编译错误
- vscode下的Arduino代码出现意外编译错误
- 第三方 API 中的编译错误 - Visual Studio
- std::cout输出int时出现编译错误
- 奇怪的代码抛出编译错误模板< J,int aSize=10> C2143:语法错误:在"<"之前缺少";"
- 提升图广度优先搜索前置编译错误
- C++ 中的编译错误:未定义对"主"的引用 collect2:错误:ld 返回 1 个退出状态
- 使用带有 ref 参数的成员函数创建线程时出现编译错误
- 我在C++中遇到了这个奇怪的编译错误
- 在C++中使用 Catch 测试框架编译错误"error: expected ';' at end of declaration list"
- 使用 std::enable_if 限制派生类的模板参数时出现编译错误
- 现代OpenGL和GLEW Libraray的编译错误
- C++ 编译错误:意外的类型名称"字符串":预期的表达式
- C ++程序编译错误,找不到/访问文件
- 使用直接大括号初始化时,C++ 编译错误"声明末尾的预期";"
- 为什么传递非静态成员函数会导致编译错误?