Hello all,<div><br></div><div>We are experiencing problems when linking our tests for a simple library after switching to ITK4.</div><div>Our library is a dll. With itk3.20 we used to link it against ITKIO but following some advices from and is linked with ${ITK_LIBRARIES}.</div>
<div><br></div><div>we have something like this in our testing's CMakeLists.txt:</div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">(...)</font></div><div><font face="courier new, monospace"><span># Link the executables to the required libraries.</span><br>
<span>IF (${ITK_VERSION_MAJOR} GREATER 3)</span><br><span> SET(MY_ITK_LIBRARIES ${ITK_LIBRARIES})</span><br><span>ELSE ()</span><br><span> SET(MY_ITK_LIBRARIES ITKIO)</span><br>
<span>ENDIF ()</span> <br clear="all"></font><div><font face="courier new, monospace">(...)</font></div><div><br></div><div>Now, with ITK4 both the library and the test exes link with <span>${ITK_LIBRARIES} so the linker complains about redefined symbols:</span></div>
<div><font color="#222222" face="arial, sans-serif"><br></font></div><div><span style>1>------ Build started: Project: TestAlgorithms, Configuration: Release Win32 ------</span><br style><span style>1> Building Custom Rule C:/cygwin/users/fpcx/soft/</span><span style>Alma-in-server/AuxTools/</span><span style>AuxITK/AuxITKLib/Testing/</span><span style>CMakeLists.txt</span><br style>
<span style>1> CMake does not need to re-run because C:\users\bin\Alma-in-server\</span><span style>AuxTools\AuxITK\AuxITKLib\dll\</span><span style>win32-vs10-release-build\</span><span style>Testing\CMakeFiles\generate.</span><span style>stamp is up-to-date.</span><br style>
<span style>1>ITKCommon-4.1.lib(</span><span style>itkDataObject.obj) : error LNK2005: "public: class itk::ProcessObject * __thiscall itk::</span><span style>SmartPointerForwardReference<</span><span style>class itk::ProcessObject>::operator-</span><span style>>(void)const " (??C?$</span><span style>SmartPointerForwardReference@</span><span style>VProcessObject@itk@@@itk@@</span><span style>QBEPAVProcessObject@1@XZ) already defined in AuxITKLib.lib(AuxITKLib.dll)</span><br style>
<span style>1>ITKCommon-4.1.lib(</span><span style>itkDataObject.obj) : error LNK2005: "public: __thiscall itk::</span><span style>SmartPointerForwardReference<</span><span style>class itk::ProcessObject>::operator class itk::ProcessObject *(void)const " (??B?$</span><span style>SmartPointerForwardReference@</span><span style>VProcessObject@itk@@@itk@@</span><span style>QBEPAVProcessObject@1@XZ) already defined in AuxITKLib.lib(AuxITKLib.dll)</span><br style>
<span style>1>ITKCommon-4.1.lib(</span><span style>itkDataObject.obj) : error LNK2005: "public: __thiscall itk::</span><span style>SmartPointerForwardReference<</span><span style>class itk::ProcessObject>::~</span><span style>SmartPointerForwardReference<</span><span style>class itk::ProcessObject>(void)" (??1?$</span><span style>SmartPointerForwardReference@</span><span style>VProcessObject@itk@@@itk@@QAE@</span><span style>XZ) already defined in AuxITKLib.lib(AuxITKLib.dll)</span><br style>
<span style>1> Creating library C:/users/bin/Alma-in-server/</span><span style>AuxTools/AuxITK/AuxITKLib/dll/</span><span style>win32-vs10-release-build/</span><span style>Testing/Release/</span><span style>TestAlgorithms.lib and object C:/users/bin/Alma-in-server/</span><span style>AuxTools/AuxITK/AuxITKLib/dll/</span><span style>win32-vs10-release-build/</span><span style>Testing/Release/</span><span style>TestAlgorithms.exp</span><br style>
<span style>1>C:\users\bin\Alma-in-server\</span><span style>AuxTools\AuxITK\AuxITKLib\dll\</span><span style>win32-vs10-release-build\</span><span style>Testing\Release\</span><span style>TestAlgorithms.exe : fatal error LNK1169: one or more multiply defined symbols found</span><br style>
<span style>========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========</span>
</div><div><br></div><div>If we don't link the test exes with <span style="font-family:'courier new',monospace">${ITK_LIBRARIES}</span><font face="arial, helvetica, sans-serif"> , then the compiler claims that there are undefined symbols.</font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">We can overcome the problem by using compiler-specific flags such as /FORCE:MULTIPLE (Visual Studio) and --allow-multiple-definition (gcc) but this seems to be treating the symptoms and not the disease... Any hint on how to link properly the exes?</font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Thanks</font></div>-- <br>Sergio Vera<br><br>
Alma IT Systems<br> C/ Vilana, 4B, 4º 1ª<br> 08022 Barcelona<br> T. <a href="tel:%28%2B34%29%20932%20380%20592" value="+34932380592" target="_blank">(+34) 932 380 592</a><br>
<a href="http://www.alma3d.com" target="_blank">www.alma3d.com</a><br>
</div>