1

I am trying to use the DirectXTex library but everytime I try, the compiler keeps giving me one error after another. More specifically, I want to use the headers DDSTextureLoader.h and WICTextureLoader.h so that I can use the functions CreateWICTextureFromFile and CreateDDSTextureFromFile so i can load textures onto my Direct3D11 application. But the compiler gives me 3 errors:

Function 'DXGI_FORMAT MakeSRGB (DXGI_FORMAT)' already has a body

'=': unable to resolve function overload this error repeats 2 times

'SetDebugObjectName': ambiguous call to overloaded function this error repeats 3 times

Compiler also says that these errors come from the file WICTextureLoader.cpp

I'm not sure what to do to fix these errors...Down below is my code (I included all the header files that I used in my game)

#include <windows.h>    
#include <D3D11.h>                  
#include <dinput.h> 
#include <D3Dcompiler.h>            
#include <DDSTextureLoader.h>
#include <WICTextureLoader.h>
#include <sstream>
#include <SimpleMath.h>
#include <SpriteFont.h>
#include "DDSTextureLoader.cpp"
#include "WICTextureLoader.cpp"

CreateDDSTextureFromFile(device, L"SpaceSky512.dds", &SkyTexture, &SkyTextureResource);
CreateWICTextureFromFile(device, DevContext, L"grass.jpg", NULL, &Texture, 0);

I stopped using the headers from the legacy directX SDK and started using the windows SDK like most people. But how can i fix the compiler errors?

1 Answers1

1

These lines appear to be the source of your problem:

#include "DDSTextureLoader.cpp"
#include "WICTextureLoader.cpp"

You should only include header files in your source files, not other source files. Instead you should link your application against the DirectXTK library.

legalize
  • 2,214
  • 18
  • 25
  • The ``DDSTextureLoader.cpp`` and ``WICTextureLoader.cpp`` modules are already in the DirectXTK library. You can either use NuGet or project-to-project references to add DirectXTK to your project. See the DirectX Tool Kit [wiki](https://github.com/Microsoft/DirectXTK/wiki/DirectXTK). – Chuck Walbourn Nov 23 '15 at 20:55