[Insight-developers] Explicit instantiation linking issues on
mac platform
Julien Jomier
julien.jomier at kitware.com
Wed Sep 6 17:55:27 EDT 2006
Hans,
Do you get the error when compiling ITK or an external program using ITK?
Julien
Hans Johnson wrote:
> Zach,
>
> I should have been more explicit earlier, but I am building statically, and
> the errors are occuring at link time rather than at run time. The manual
> fix is to re-arrange the library link order to put -lITKCommonExplicit
> before -lITKCommon. When I get back to that machine, I'll give a concrete
> example.
>
> The errors are of the "symbol not found" link error, and the symbols are
> ones needed by ITKCommonExplicit and found in ITKCommon.
>
> Thanks,
> Hans
>
>
>
> On 9/6/06 4:38 PM, "Zachary Pincus" <zpincus at stanford.edu> wrote:
>
>> I think that the TARGET_LINK_LIBRARIES statement is trying to link
>> ITKCommonExplicit into the ITKCommon library, so that an app can just
>> link to the common lib and the explicit one will be pulled in.
>>
>> Is that not working? What are the link errors you see when building
>> applications?
>>
>> You can check what libraries are linked to an object file (executable
>> or other library) on OS X with 'otool -L'. It would be worth checking
>> what's linked to libITKCommon.dylib, and in what order.
>>
>> Zach
>>
>> On Sep 6, 2006, at 8:20 AM, Hans Johnson wrote:
>>
>>> Hello Fellow Developers!
>>>
>>> I wanted to alert the group to a small issue with linking on mac
>>> platform
>>> with explicit instantiation, and get some advice on how to fix the
>>> problem.
>>>
>>> The issue is that when explicit instantiation is used the extra
>>> ITKCommonExplicit library needs to be linked into the applications
>>> along
>>> with ITKCommon library. The file Insight/Code/Common/
>>> CMakeLists.txt code
>>> has the following
>>>
>>> IF(ITK_EXPLICIT_INSTANTIATION)
>>> TARGET_LINK_LIBRARIES (ITKCommon ITKCommonExplicit)
>>> ENDIF(ITK_EXPLICIT_INSTANTIATION)
>>>
>>> Which I interpret as "ITKCommon depends upon ITKCommonExplicit, so
>>> whenever
>>> you use -lITKCommon then also follow with -lITKCommonExplicit
>>> during linking
>>> stages". The problem is that the linking dependancies are
>>> backwards, and
>>> that ITKCommonExplicit needs to preceed ITKCommon.
>>>
>>> What needs to happen is that somehow ITKCommonExplicit needs to be
>>> prepended
>>> to many of the linking stages.
>>>
>>> I would like some guidance on resolving this issues, because the
>>> "easy way"
>>> touches quite a lot of CmakeLists.txt files and adds complexity to
>>> linking
>>> logic.
>>>
>>>
>>> Regards,
>>> Hans
>>>
>>> Food For Thought---Another less intrusive way to do this would be
>>> to have
>>> conditionals in the Insight/Code/Common/CMakeLists.txt file that
>>> builds the
>>> explicit instantiations right into the ITKCommon library rather
>>> than having
>>> a separate library. This will make life a lot easier as the number
>>> and
>>> names of the library linking would be constant across configuration
>>> options.
>>>
>>>
>>> _______________________________________________
>>> Insight-developers mailing list
>>> Insight-developers at itk.org
>>> http://www.itk.org/mailman/listinfo/insight-developers
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers
>
More information about the Insight-developers
mailing list