InsightSoftwareConsortium / ITK

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.
https://itk.org
Apache License 2.0
1.4k stars 663 forks source link

5.4 ITK Failed to build(CMake) with error LNK2005: __ucrt_int_to_float already defined #4820

Open wbkangtc opened 2 weeks ago

wbkangtc commented 2 weeks ago

Description

Fails to build on CMake 3.30.1 Windows SDK version 10.0.26100.0 to target Windows 10.0.22631. [build] -- Using MSVC's dynamic CRT (/MD and /MDd) With error message

[build]     itktiff.vcxproj -> C:\TSS\build\Extern\ITK\src\ITK-build\lib\Debug\itktiff-5.4.lib
[build] itktiff-5.4.lib(tif_luv.obj) : error LNK2005: __ucrt_int_to_float already defined in itktiff-5.4.lib(tif_aux.obj) [C:\TSS\build\Extern\ITK\src\ITK-build\Modules\IO\TIFF\src\ITKIOTIFF.vcxproj] [C:\TSS\build\ITK.vcxproj]
[build] itktiff-5.4.lib(tif_color.obj) : error LNK2005: __ucrt_int_to_float already defined in itktiff-5.4.lib(tif_aux.obj) [C:\TSS\build\Extern\ITK\src\ITK-build\Modules\IO\TIFF\src\ITKIOTIFF.vcxproj] [C:\TSS\build\ITK.vcxproj]

Steps to Reproduce

  1. Attempt build.
    ExternalProject_add(ITK
      PREFIX ${CMAKE_BINARY_DIR}/Extern/ITK
      GIT_REPOSITORY https://github.com/InsightSoftwareConsortium/ITK.git
      GIT_TAG v5.4.0
      UPDATE_COMMAND ""
      CMAKE_ARGS
        -DBUILD_EXAMPLES:BOOL=OFF
        -DBUILD_SHARED_LIBS:BOOL=ON
        -DBUILD_TESTING:BOOL=OFF
        -DCMAKE_BUILD_TYPE:STRING=${CUSTOM_BUILD_TYPE}
        -DITK_BUILD_DEFAULT_MODULES:BOOL=ON
        -DModule_ITKReview:BOOL=ON
        -DITK_LEGACY_REMOVE:BOOL=ON
        -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_DEPENDENCIES_DIR}/ITK
        -DITK_USE_SYSTEM_HDF5:BOOL=OFF
        -DModule_ITKVtkGlue:BOOL=OFF
        -DHDF5_ROOT:STRING=${HDF5_ROOT}
      INSTALL_DIR ${INSTALL_DEPENDENCIES_DIR}
      DEPENDS HDF5
    )

Expected behavior

Build

Actual behavior

[build]     itktiff.vcxproj -> C:\TSS\build\Extern\ITK\src\ITK-build\lib\Debug\itktiff-5.4.lib
[build] itktiff-5.4.lib(tif_luv.obj) : error LNK2005: __ucrt_int_to_float already defined in itktiff-5.4.lib(tif_aux.obj) [C:\TSS\build\Extern\ITK\src\ITK-build\Modules\IO\TIFF\src\ITKIOTIFF.vcxproj] [C:\TSS\build\ITK.vcxproj]
[build] itktiff-5.4.lib(tif_color.obj) : error LNK2005: __ucrt_int_to_float already defined in itktiff-5.4.lib(tif_aux.obj) [C:\TSS\build\Extern\ITK\src\ITK-build\Modules\IO\TIFF\src\ITKIOTIFF.vcxproj] [C:\TSS\build\ITK.vcxproj]

Reproducibility

100

Versions

v5.4.0

Environment

Fails to build on CMake 3.30.1 Windows SDK version 10.0.26100.0 to target Windows 10.0.22631. [build] -- Using MSVC's dynamic CRT (/MD and /MDd) MSVC 17.10 (VS2022)

Additional Information

github-actions[bot] commented 2 weeks ago

Thank you for contributing an issue! 🙏

Welcome to the ITK community! 🤗👋☀️

We are glad you are here and appreciate your contribution. Please keep in mind our community participation guidelines. 📜 Also, please check existing open issues and consider discussion on the ITK Discourse. 📖

This is an automatic message. Allow for time for the ITK community to be able to read the issue and comment on it.

wbkangtc commented 2 weeks ago

So this also happens for VS2019 build with toolset v142.

jakimmel commented 2 weeks ago

You can get the build to complete by adding "/FORCE:MULTIPLE" to the linker command line. TBD whether or not this causes issues in practice though.