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&#39;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&gt;------ Build started: Project: TestAlgorithms, Configuration: Release Win32 ------</span><br style><span style>1&gt;  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&gt;  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&gt;ITKCommon-4.1.lib(</span><span style>itkDataObject.obj) : error LNK2005: &quot;public: class itk::ProcessObject * __thiscall itk::</span><span style>SmartPointerForwardReference&lt;</span><span style>class itk::ProcessObject&gt;::operator-</span><span style>&gt;(void)const &quot; (??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&gt;ITKCommon-4.1.lib(</span><span style>itkDataObject.obj) : error LNK2005: &quot;public: __thiscall itk::</span><span style>SmartPointerForwardReference&lt;</span><span style>class itk::ProcessObject&gt;::operator class itk::ProcessObject *(void)const &quot; (??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&gt;ITKCommon-4.1.lib(</span><span style>itkDataObject.obj) : error LNK2005: &quot;public: __thiscall itk::</span><span style>SmartPointerForwardReference&lt;</span><span style>class itk::ProcessObject&gt;::~</span><span style>SmartPointerForwardReference&lt;</span><span style>class itk::ProcessObject&gt;(void)&quot; (??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&gt;     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&gt;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&#39;t link the test exes with <span style="font-family:&#39;courier new&#39;,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>