ITK: GDCM fails to compile using MSVC 2019, 2022 after bump to 3.0.23
Description
GDCM fails to compile using MSVC 2019, 2022: https://open.cdash.org/index.php?project=Insight&date=2024-03-26 vs https://open.cdash.org/index.php?project=Insight&date=2024-03-27
with the errors:
T:\Dashboard\ITK\Modules\ThirdParty\GDCM\src\gdcm\Source\Common\gdcmSystem.cxx(905,3):
error C3861: 'gettimeofday': identifier not found
and
T:\Dashboard\ITK\Modules\ThirdParty\MINC\src\libminc\volume_io\Prog_utils\time.c(133,20):
error C2079: 'tv' uses undefined struct 'timeval'
Errors appeared after GDCM was bumped from 3.0.22 to 3.0.23 in 919cf42.
Not sure why this was not reported by Azure Pipelines, which uses MSVC 2019: https://github.com/InsightSoftwareConsortium/ITK/blob/master/Testing/ContinuousIntegration/AzurePipelinesWindows.yml#L83
Steps to Reproduce
Have a Windows system with MSVC 2019 or 2022 (may happen on newer versions)
- Clone ITK
master - Configure and generate
- Build project
Expected behavior
No compiler errors are reported.
Actual behavior
Build fails with the errors:
T:\Dashboard\ITK\Modules\ThirdParty\GDCM\src\gdcm\Source\Common\gdcmSystem.cxx(905,3):
error C3861: 'gettimeofday': identifier not found
and
T:\Dashboard\ITK\Modules\ThirdParty\MINC\src\libminc\volume_io\Prog_utils\time.c(133,20):
error C2079: 'tv' uses undefined struct 'timeval'
Reproducibility
100%
Versions
ITK master.
Environment
OS: Windows Compiler: MSVC 2019, 2022
Additional Information
File at issue at GDCM 3.0.23: https://github.com/malaterre/GDCM/blob/v3.0.23/Source/Common/gdcmSystem.cxx
File at issue at GDCM 3.0.22: https://github.com/malaterre/GDCM/blob/v3.0.22/Source/Common/gdcmSystem.cxx
They are exactly the same, so maybe it is this block, where gettimeofday is defined, that is not being compiled: https://github.com/malaterre/GDCM/blob/master/Source/Common/gdcmSystem.cxx#L644-L725
About this issue
- Original URL
- State: closed
- Created 3 months ago
- Reactions: 1
- Comments: 20 (20 by maintainers)
Commits related to this issue
- Fix a compile issue caused by vcpkg providing a symbol at link time See https://github.com/InsightSoftwareConsortium/ITK/issues/4552 — committed to dzenanz/libminc by dzenanz 3 months ago
- COMP: Fix https://github.com/InsightSoftwareConsortium/ITK/issues/4552 — committed to malaterre/GDCM by dzenanz 3 months ago
- Prefer CheckSymbolExists over CheckFunctionExists This is a legacy cmake function anyway. It appears that recent Visual Studio compiler fails the test now. Should fix https://github.com/InsightSoftw... — committed to thewtex/GDCM by dzenanz 3 months ago
Maybe
gettimeofdayshould just be replaced by using modern C++std::chronoinstead 🤷std::chronois certainly platform independent.Yes, I also think it would simplify the code (no need to check with cmake). BTW, the issue will not be completely resolved with the PR, MINC will fail.
I now think this might be due to some Windows update, or CMake version. I tried several versions of GDCM, up to 3.0.2 from 2019, and they all run into the same compile error, in both VS2022 and VS2019.
It seems that on many Windows machines the build doesn’t fail, e.g. zeratul2.kitware, on the dashboard ryzenator.kitware seems to fail.
MINC build fails (similar, related to ‘time’ stuff) too. Interesting.