Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failures on Windows for conda-forge package #1547

Open
ghisvail opened this issue Jun 3, 2023 · 10 comments
Open

Build failures on Windows for conda-forge package #1547

ghisvail opened this issue Jun 3, 2023 · 10 comments
Labels
help needed Issues that require feedback or expertise from the community. Discussion and PRs welcome

Comments

@ghisvail
Copy link
Contributor

ghisvail commented Jun 3, 2023

When did the error occur?

[ ] CMake configuration (cmake / ccmake)
[x] Compilation (make)
[ ] Installation (make install)

Build environment

  • OS: Windows
  • Type of system: conda-forge CI

ANTs version

Version 2.4.4

Build configuration and logs

https://dev.azure.com/conda-forge/84710dde-1620-425b-80d0-4cf5baca359d/_apis/build/builds/717445/logs/25

Additional context

I have resumed my effort for providing a Conda package for ANTs via conda-forge. It builds fine on Linux and macOS but fails on Windows with a linking error.

2023-06-03T20:49:24.5910710Z [20/427] Linking CXX executable Examples\antsAffineInitializer.exe
2023-06-03T20:49:24.5911565Z FAILED: Examples/antsAffineInitializer.exe 
2023-06-03T20:49:24.5913080Z cmd.exe /C "cd . && %BUILD_PREFIX%\Library\bin\cmake.exe -E vs_link_exe --intdir=Examples\CMakeFiles\antsAffineInitializer.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests  -- C:\PROGRA~2\MICROS~2\2019\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\antsAffineInitializer.rsp  /out:Examples\antsAffineInitializer.exe /implib:Examples\antsAffineInitializer.lib /pdb:Examples\antsAffineInitializer.pdb /version:0.0 /machine:x64  /INCREMENTAL:NO /subsystem:console  && cd ."
2023-06-03T20:49:24.5916778Z LINK: command "C:\PROGRA~2\MICROS~2\2019\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\antsAffineInitializer.rsp /out:Examples\antsAffineInitializer.exe /implib:Examples\antsAffineInitializer.lib /pdb:Examples\antsAffineInitializer.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console /MANIFEST /MANIFESTFILE:Examples\antsAffineInitializer.exe.manifest" failed (exit code 1169) with the following output:
2023-06-03T20:49:24.5919417Z LINK : warning LNK4044: unrecognized option '/lpthreads'; ignored
2023-06-03T20:49:24.5920686Z ITKOptimizers-5.3.lib(ITKOptimizers-5.3.dll) : error LNK2005: "protected: __cdecl itk::CostFunctionTemplate<double>::CostFunctionTemplate<double>(void)" (??0?$CostFunctionTemplate@N@itk@@IEAA@XZ) already defined in antsUtilities.lib(antsRegistration4DDouble.cxx.obj)
2023-06-03T20:49:24.5922719Z ITKOptimizers-5.3.lib(ITKOptimizers-5.3.dll) : error LNK2005: "protected: virtual __cdecl itk::CostFunctionTemplate<double>::~CostFunctionTemplate<double>(void)" (??1?$CostFunctionTemplate@N@itk@@MEAA@XZ) already defined in antsUtilities.lib(antsRegistration4DDouble.cxx.obj)
2023-06-03T20:49:24.5924701Z ITKOptimizers-5.3.lib(ITKOptimizers-5.3.dll) : error LNK2005: "protected: virtual void __cdecl itk::CostFunctionTemplate<double>::PrintSelf(class std::basic_ostream<char,struct std::char_traits<char> > &,class itk::Indent)const " (?PrintSelf@?$CostFunctionTemplate@N@itk@@MEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@VIndent@2@@Z) already defined in antsUtilities.lib(antsRegistration4DDouble.cxx.obj)
2023-06-03T20:49:38.3031489Z Examples\antsAffineInitializer.exe : fatal error LNK1169: one or more multiply defined symbols found

I would not mind skipping the Windows builds, but since you all made the efforts to provide Windows binaries lately, I was hopeful we could make it happen too for Conda.

@ghisvail ghisvail changed the title Build failures on Windows in conda-forge package Build failures on Windows for conda-forge package Jun 3, 2023
@cookpa cookpa added the help needed Issues that require feedback or expertise from the community. Discussion and PRs welcome label Jun 5, 2023
@cookpa
Copy link
Member

cookpa commented Jun 5, 2023

Thanks for working on this. The only Windows builds I do are via the Actions workflow, so unless anyone else can help, you might have to go ahead without Windows.

@cookpa
Copy link
Member

cookpa commented Jun 9, 2023

I noticed while working on ANTsPy that the Windows builds there all turn shared libraries off (eg ANTsX/ANTsPy#345). I'm guessing that Conda needs shared libs turned on, but maybe this context will help narrow the search for solutions.

@cookpa
Copy link
Member

cookpa commented Jun 16, 2023

Further update: Superbuild works on Windows with shared libs. So ANTs can build on Windows with shared libs on, so maybe the error is specific to using system ITK on Windows.

https://github.com/cookpa/ANTs/actions/runs/5291048324

Edit to add runner info:

CMake 3.26.4
Building for: Visual Studio 17 2022
-- The C compiler identification is MSVC 19.36.32532.0
-- The CXX compiler identification is MSVC 19.36.32532.0

@cookpa
Copy link
Member

cookpa commented Jun 26, 2023

Thanks for all your efforts on this, @ghisvail !

@ghisvail
Copy link
Contributor Author

ANTs is now available on conda-forge 🥳

I am trying my best to enable builds for Windows.

@ntustison
Copy link
Member

Awesome. Thanks for this.

@ghisvail
Copy link
Contributor Author

Still no luck with Windows on the conda-forge CI setup. No idea why I get these link errors for multiple definitions on Windows and not on macOS and Linux.

[20/426] Linking CXX executable Examples\antsAffineInitializer.exe
FAILED: Examples/antsAffineInitializer.exe 
cmd.exe /C "cd . && %BUILD_PREFIX%\Library\bin\cmake.exe -E vs_link_exe --intdir=Examples\CMakeFiles\antsAffineInitializer.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests  -- C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\HostX64\x64\link.exe /nologo @CMakeFiles\antsAffineInitializer.rsp  /out:Examples\antsAffineInitializer.exe /implib:Examples\antsAffineInitializer.lib /pdb:Examples\antsAffineInitializer.pdb /version:0.0 /machine:x64  /INCREMENTAL:NO /subsystem:console  && cd ."
LINK: command "C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\HostX64\x64\link.exe /nologo @CMakeFiles\antsAffineInitializer.rsp /out:Examples\antsAffineInitializer.exe /implib:Examples\antsAffineInitializer.lib /pdb:Examples\antsAffineInitializer.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console /MANIFEST /MANIFESTFILE:Examples\antsAffineInitializer.exe.manifest" failed (exit code 1169) with the following output:
LINK : warning LNK4044: unrecognized option '/lpthreads'; ignored
ITKOptimizers-5.3.lib(ITKOptimizers-5.3.dll) : error LNK2005: "protected: __cdecl itk::CostFunctionTemplate<double>::CostFunctionTemplate<double>(void)" (??0?$CostFunctionTemplate@N@itk@@IEAA@XZ) already defined in antsUtilities.lib(antsRegistration4DDouble.cxx.obj)
ITKOptimizers-5.3.lib(ITKOptimizers-5.3.dll) : error LNK2005: "protected: virtual __cdecl itk::CostFunctionTemplate<double>::~CostFunctionTemplate<double>(void)" (??1?$CostFunctionTemplate@N@itk@@MEAA@XZ) already defined in antsUtilities.lib(antsRegistration4DDouble.cxx.obj)
ITKOptimizers-5.3.lib(ITKOptimizers-5.3.dll) : error LNK2005: "protected: virtual void __cdecl itk::CostFunctionTemplate<double>::PrintSelf(class std::basic_ostream<char,struct std::char_traits<char> > &,class itk::Indent)const " (?PrintSelf@?$CostFunctionTemplate@N@itk@@MEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@VIndent@2@@Z) already defined in antsUtilities.lib(antsRegistration4DDouble.cxx.obj)
Examples\antsAffineInitializer.exe : fatal error LNK1169: one or more multiply defined symbols found

@cookpa
Copy link
Member

cookpa commented Jun 27, 2023

It is a mystery. Are you sure that the ITK build you are linking against was compiled with the same settings? I read that incompatible compilers can cause this error.

@ghisvail
Copy link
Contributor Author

Are you sure that the ITK build you are linking against was compiled with the same settings?

I just checked, both are compiled with the same compiler (vs2019) according to their CI manifests.

@cookpa
Copy link
Member

cookpa commented Jun 27, 2023

I found an example of the same problem: https://discourse.itk.org/t/link-error-on-declaring-metrics-in-two-different-classes/2600

It seems like might be solvable on the ANTs side by resolving the duplicate imports, but would probably involve a lot of work. I guess other platform compilers are tolerant of these conflicts somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help needed Issues that require feedback or expertise from the community. Discussion and PRs welcome
Projects
None yet
Development

No branches or pull requests

3 participants