Search code examples
c++windowsxboxgamepaddirectxtk

CoInitialize has not been called - (loading gamepad.h from DirectXTK without library)


I am using the DirectXTK library for the gamepad class. I compiled the library with only this class inside it and it works.

If I would only add the source files to my project, without the library, the size would be ~50KB instead of ~500KB. However, I am receiving the following error:

CoInitialize has not been called

Any ideas on how to resolve this so my executable would be smaller in size?


Solution

  • Well, you could call CoInitialize yourself as the first thing in main.

    int main()
    {
        CoInitialize(NULL);
    
        // your code
    
        return 0;
    }