gabime / spdlog

Fast C++ logging library.
Other
24k stars 4.5k forks source link

spdlog example project doesn't work when built with Visual Studio 2022 and run on Windows 7 #3167

Closed jaredhagel2 closed 2 weeks ago

jaredhagel2 commented 3 weeks ago

I build spdlog using the following commands:

git clone https://github.com/gabime/spdlog.git cd spdlog && mkdir build && cd build cmake .. -G "Visual Studio 17 2022" -A WIN32 && cmake --build . --config Debug

Then I copy spdlog\build\example\Debug\example.exe to my Windows 7 device and run it there. spdlog crashes, and I get the following stack trace in the dump file that's generated. image

According to that stack trace, the crash occurs when executing this line (line 39) in the example project: spdlog::info("Welcome to spdlog version {}.{}.{} !", SPDLOG_VER_MAJOR, SPDLOG_VER_MINOR, SPDLOG_VER_PATCH);

Does anybody have ideas how I can troubleshoot this? We have customers that use Windows 7 devices that we need to support.

Note that this problem only occurs when spdlog is built with Visual Studio 2022. Running on Windows 7 works fine if spdlog is built with Visual Studio 2019 using the command below. cmake .. -G "Visual Studio 16 2019" -A WIN32 && cmake --build . --config Debug

tt4g commented 3 weeks ago

Is Visual Studio Runtime compatible with Visual Studio 2022 installed on a Windows 7 machine? Version compatibility between MSVC version and runtime is important for C++ projects.

tt4g commented 3 weeks ago

Note that to build for older version Windows, you must build your project with the WINVER and _WIN32_WINNT macros set to values that support the older version Windows.

See: Update WINVER and _WIN32_WINNT | Microsoft Learn

jaredhagel2 commented 3 weeks ago

I'll give this a try (ie. setting WINVER and _WIN32_WINNT to specify the minimum operating system version my code supports). Thanks for the quick feedback!

jaredhagel2 commented 2 weeks ago

Just an update on what I have decided to do - since spdlog built with Visual Studio 2019 works fine when run on Windows 7, I've decided to build my project with Visual Studio 2019. I was not able to find a way to make spdlog work on Windows 7 when built with the Visual Studio 2022 toolset.

tt4g commented 2 weeks ago

@jaredhagel2 Looks like the same problem as the following link.

Since this is a DLL problem, I think you should contact Microsoft.