COM CoInitialize Warning on glfwInit call

I created a new test project with Visual Studio 2017, changed the settings as described below.

  • Additional Include Directories: C:\Users\Owner\Documents\Visual Studio 2017\Libraries\glfw-3.3.2.bin.WIN64\include;%(AdditionalIncludeDirectories)
  • Linker - Additional Library Directories: C:\Users\Owner\Documents\Visual Studio 2017\Libraries\glfw-3.3.2.bin.WIN64\lib-vc2017;%(AdditionalLibraryDirectories)
  • Linker - Additional Dependencies: opengl32.lib;glfw3.lib;%(AdditionalDependencies)

I then copy-pasted the code off of https://www.glfw.org/documentation.html into main.cpp. I then compiled the program with the Debug configuration, targeting the x64 platform.

The program ran perfectly fine, however, within the VS output window, it displayed the following:

onecore\com\combase\objact\objact.cxx(836)\combase.dll!00007FFD097B3D87: (caller: 00007FFD097B2C0C) ReturnHr(1) tid(4724) 800401F0 CoInitialize has not been called.
onecore\com\combase\objact\objact.cxx(836)\combase.dll!00007FFD097B3D87: (caller: 00007FFD097B2C0C) ReturnHr(2) tid(4724) 800401F0 CoInitialize has not been called.
onecore\com\combase\objact\objact.cxx(836)\combase.dll!00007FFD097B3D87: (caller: 00007FFD097B2C0C) ReturnHr(3) tid(4724) 800401F0 CoInitialize has not been called.
onecore\com\combase\objact\objact.cxx(836)\combase.dll!00007FFD097B3D87: (caller: 00007FFD097B2C0C) ReturnHr(4) tid(4724) 800401F0 CoInitialize has not been called.

These warnings persist in the Release configuration.

Stepping through the example using the debugger, I found that these are generated after the call to glfwInit.

Is there any solution to this?

Do you get the same warnings on any of the tests or example projects in GLFW, or in this starter project: https://github.com/juliettef/GLFW-CMake-starter ?

I heard someone had a similar issue which I was unable to replicate:

If you can replicate the issue with any of the tests/examples etc. then it might be an issue with GLFW on your particular configuration, so knowing the exact OS details would be useful (Windows version).

I cloned that starter project, built it with cmake, yielding the following info:

Building for Visual Studio 15 2017
Selecting Windows SDK Version 10.0.17763.0 to target Windows 10.0.18363.
The C compiler identification is MSVC 19.16.27039.0
The CXX compiler identification is MSVC 19.16.27039.0

I am using Windows 10 Home x64-bit, version 1909, build 18363.778

The problem persisted when I compiled and ran the solution (targeting Debug Win32)

Just in case it’s relevant, I am compiling and running this on an Intel Core i3-8100.

Thanks - I don’t think this is a bug in GLFW as it’s not using COM directly, but since two people have seen it it may be worth filing a GLFW issue. I can do this for you if you don’t have a Github account.

There are a few things I can think of which might cause this, one being a driver bug and the other being an external application which injects itself into apps.

Basically CoInitializeEx isn’t being called by something which uses COM: https://docs.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-coinitializeex

1 Like

Okay. I filed the issue. Hopefully this will prove to be recreatable in a few more cases. Thankfully this seems to not a have a significantly negative impact.
https://github.com/glfw/glfw/issues/1681