如何在MingW中编译directX教程示例 [英] How do I compile a directX tutorial sample in MingW

查看:190
本文介绍了如何在MingW中编译directX教程示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索过,并且找不到在MingW下直接编译directX的方法,我已经看到其他人成功了,并试图复制它无济于事。我已经阅读过这个类似的问题,但没有帮助,所以请不要直接告诉我:如何在MinGW中编译DirectX 11应用程序



我一直试图让MingW与directX现在已经很长时间了,下面列出了我失败的尝试和我读过的其他内容:


  • 下载MSVC头文件并使用它们

  • 下载MingW-W64并使用它编译

  • 下载Reubens MingW-W64并使用它编译

  • 下载最新的MingW编译器并使用它

  • 下载TDM-GCC并使用它。

  • 混合编译器头文件试图让错误消失



听说我应该至少能够在链接器阶段失败如果我只是将directX头文件转储到适当的位置,但我得到语法错误文件即使在我做到了这一点后(即使他们中的大部分都离开了),每一个编译器都会有自己独特的错误,在不同的点上失败,但在某些点出现失败的地方显然会成功。到底是怎么回事?为什么完全有效的代码(全部由微软编写)在被任何其他编译器处理时突然无法编译?解析方案

包含DirectX 2010 2010 SDK远不是完美的有效代码。他们使用了许多特定于微软编译器的扩展。



在我放弃它之前基本上没有希望了,我在编译示例时发现了以下微软的特定依赖项在 Samples \C ++ \Direct3D\BasicHLSL





微软的DirectX头文件也存在问题,我没有提及,例如依赖微软的 SAL批注宏。可以说这是由于没有兼容版本的DirectX头文件而导致MinGW失败。



这些问题中的一些相对容易解决。其他则更加困难,需要重写样本中不兼容的部分。样本中也可能有更多微软依赖项,我没有发现。



底线是无法编译DirectX附带的示例使用MinGW或GCC的任何其他端口的SDK,无需先修改样本和DXUT框架,以使它们更加便携。


I have searched and searched and found no way to get directX to compile under MingW, I've seen others success and tried to replicate it to no avail. I've already read this similar question and it didn't help so please don't direct me to it: How to compile a DirectX 11 app in MinGW.

I've been trying to get MingW to cooperate with directX for a long time now, here is a list of my failed attempts and what I've read worked for others:

  • Download MSVC headers and have MingW use them
  • Download MingW-W64 and use it to compile
  • Download Reubens MingW-W64 and use it to compile
  • Download the most up to date MingW compiler and use it
  • Download TDM-GCC and use it.
  • mix compiler headers in a desperate attempt to make errors go away

I heard that I should be able to at least get to fail at the linker phase if I just dump the directX headers into the appropriate place, but I'm getting syntax errors left and right even after I did that (granted the bulk of them went away.) Each compiler ends up with its own unique errors, failing at different points but appearently succeeding in places where the others fail at some points. What is going on? Why does perfectly valid code (all written by microsoft) suddenly fail to compile when handled by any other compiler?

解决方案

Unfortunately the samples include with the DirectX June 2010 SDK are far from "perfect valid code". They use a number of extensions specific to Microsoft's compiler.

Before I gave up on it as being essentially hopeless, I found the following Microsoft's specific dependencies when trying to compile the sample in Samples\C++\Direct3D\BasicHLSL:

  • the __noop intrinsic
  • the macros __min and __max
  • various "safe" versions of standard functions, like wsprintf_s and strcpy_s
  • non-standard pre-processor token pasting
  • allowing goto across variable initialization
  • the __uuidof operator

There are also problems with Microsoft's DirectX headers that I haven't mentioned, like being dependent on Microsoft's SAL annotation macros. Arguably though this a failing of MinGW for not having compatible versions of these DirectX headers.

Some of these problems are relatively easy to work around. Others are more difficult and would require rewriting the incompatible parts of the sample. There are also likely to be more Microsoft dependencies in the sample that I didn't discover.

The bottom line is that there's no way to compile the samples included with the DirectX SDK with MinGW or any other port of GCC without first modifying to the samples and the DXUT framework to make them more portable.

这篇关于如何在MingW中编译directX教程示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆