0

Using VS2018Pro, Windows10,

I'm getting many redefinition compilation errors when pulling in DirectXTex.h, DirectXMath.h and DirectXCollision.h across project files.

DirectXMath and DirectXCollision are part of the Win10SDK headers and I pulled DirectXTex from the github repo and put it local to my project folder.

In my code base I need to include the DirectXTex.h, DirectXMath.h and DirectXCollision.h headers across various files however I'm getting many redefintion errors and duplicates that are within the DirectX namespace. I understand that I may have to include one before the other (which I've tried many variations of, and DirectXTex pulls in DirectXMath for eg) but I can't get things to compile.

Does anyone have a clue as to the correct order of pulling in these includes across project files?

Dave
  • 117
  • 7
  • Those should all work fine together. The headers all use ``#pragma once`` so they shouldn't have dups. Can you post an example of one of these errors? – Chuck Walbourn Jul 05 '19 at 08:08
  • Make sure you are not using ``xnamath.h`` anywhere... It conflicts with DirectXMath. See [this blog post](https://walbourn.github.io/introducing-directxmath/). – Chuck Walbourn Jul 05 '19 at 08:14
  • Hi Chuck, I'm not using xnamath.h at all. Say I include DirectXCollision.h and DirectXTex.h in model.h, and sprite.h pull in the DirectXMath.h and DirectXTex then I get the errors.. – Dave Jul 06 '19 at 09:25
  • What errors in particular? – Chuck Walbourn Jul 06 '19 at 22:33
  • Oh dear ! After a weekends rest I just noticed that I had one my own headers pulling in DirectXMath.h from a clone of your DirectXMath repo (that I had cloned at the beggining of the project) while all of my other headers are pulling in DirectXMath.h from the Win10 SDK. After correcting this blatant error all is compiling great and as expected. I apologise if I've wasted any of your time. – Dave Jul 08 '19 at 00:37
  • Saying that if I was to download the latest from the DirectXMath and DirectXTex repos and have them local to the project, then put the DirectX includes into the pch.h such as // pch.h #include "../DirectXMath/Inc/DirectXMath.h" #include "../DirectXMath/Inc/DirectXCollision.h" #include "../DirectXTex/DirectXTex/DirectXTex.h" Then the redefiniton errors return due to DirectXTex.h pulling in the Win10SDK version of DirectXMath ( via using #include ) – Dave Jul 08 '19 at 01:42
  • The redefinions errors contain the structs and XM_CONST... which then leads the compiler to naturally complain about function overload errors. – Dave Jul 08 '19 at 01:46

1 Answers1

0

The solution was to move all '#include DirectX*.h" headers from the project header files into the cpp files.

Dave
  • 117
  • 7