SDL icon indicating copy to clipboard operation
SDL copied to clipboard

SDL_gameinput.cpp has line #include <game_input.h>, but game_input does not exist

Open burkelyp opened this issue 7 months ago • 5 comments

I'm on a Linux machine but trying to build sdl3 on Windows to make my application cross-platform compatible. I keep getting an error:

error C1083: Cannot open include file: 'gameinput.h': No such file or directory

and indeed the file does not exist. Anyone know what I'm doing wrong?

burkelyp avatar May 12 '25 23:05 burkelyp

This requires GameInput.h from the Microsoft redistributable: https://learn.microsoft.com/en-us/gaming/gdk/docs/features/common/input/overviews/input-overview

I'm not sure why gameinput is being enabled in CMake, @madebr, do you know what's happening here?

slouken avatar May 13 '25 02:05 slouken

This sounds like https://github.com/libsdl-org/SDL/issues/11487, but this would be the first occurrence on a non-ci system. The root issue for the ci issue was never found: they just suggested to update to windows-2025 (or use a Ninja generator).

https://github.com/libsdl-org/SDL/blob/0a34279578a2cce104efc0d605cd5a51ece25e95/CMakeLists.txt#L1973-L1978

Assuming you use CMake, what does your CMakeFiles/CMakeConfigureLog.yaml say about HAVE_GAMEINPUT_H?

madebr avatar May 13 '25 07:05 madebr

I ran into this as well and it seems it may be related to CMP0149. check_c_source_compiles appears to generate a CMakeLists that uses the newest version of CMake on your system, which can result in it targeting a different version of the Windows SDK than SDL. I fixed it locally by just setting cmake_minimum_required to to 3.27, but there may be a better solution I'm unaware of.

kbalbas avatar May 25 '25 14:05 kbalbas

When you use cmake_minimum_required(VERSION 4.0), and configure with -DCMAKE_POLICY_DEFAULT_CMP0149=OLD, then it "works"? (And configuring with -DCMAKE_POLICY_DEFAULT_CMP0149=NEW fails?) If so, may I ask what Windows SDK versions you have installed? With this information, I can report it to the CMake project.

madebr avatar May 25 '25 14:05 madebr

Keeping cmake_minimum_required(3.16) in the CMakeLists.txt: Running with -DCMAKE_POLICY_DEFAULT_CMP0149="OLD" targets Windows SDK version 10.0.19041.0 on my machine (which matches the windows version, and does not have gameinput.h). Running with -DCMAKE_POLICY_DEFAULT_CMP0149="NEW" targets Windows SDK version 10.0.26100.0 on my machine (which is the latest I have installed, and does have gameinput.h). Running without any define results in the OLD behavior.

Setting cmake_minimum_required(4.0) in the CMakeLists.txt: It doesn't accept -DCMAKE_POLICY_DEFAULT_CMP0149 at all, and therefore always targets the latest SDK version.

In all cases, running --debug-trycompile shows the HAVE_GAMEINPUT_H step generates a CMakeLists.txt that targets the latest installed version (e.g. 4.0.2.0). Which means it always targets the latest SDK, and if you have gameinput.h in that SDK, it will find it.

I believe the core issue here is that trycompile doesn't respect the CMake version the project is actually running, and can therefore yield false results with compatibility tests (in this case, due to CMP0149).

kbalbas avatar May 25 '25 16:05 kbalbas

I encountered the Cannot open include file: 'gameinput.h': No such file or directory error today when trying to compile SDL3 in a non-CI environment

Windows 11 Pro 24H2 Visual Studio Community 2019

First, I tried updating VS 2019 to the latest version because it hadn't been updated in a while (I'm primarily on macOS, and the Windows box is just for testing things). I still got the same error after updating. Then, I tried installing the optional Windows 11 SDK (10.0.22621.0) that VS 2019 offered. Again, I still got the error.

Then, I decided to try installing Visual Studio Community 2022. I did not get the error anymore with VS 2022.

joshtynjala avatar Sep 18 '25 20:09 joshtynjala