[Insight-users] Re: NumericTraits::Zero not found during WrapITK build on Windows XP

Zachary Pincus zpincus at stanford.edu
Thu Feb 16 08:22:50 EST 2006


I think that this is the same problem that we looked at yesterday, in  
a different guise.

Things like the numeric trait Zero are declared in the ITK header as
ITKCommon_Export
which is empty on non-windows systems, but
__declspec(dllimport)
when you are using the header on windows (it is __declspec(dllexport)  
when itk is building the shared lib, which makes sense.)

See the following for more explanation:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ 
vccore/html/_core_import_into_an_application_using___declspec. 
28.dllimport.29.asp

The above page notes that __declspec(dllimport) is not necessary when  
importing functions from a dll, but it is needed to import other  
symbols. Like static constants, such as numeric traits Zero and One.

As we learned before, CableSwig can't deal with these sort of  
nonstandard call attributes, and so generates code that doesn't use  
them. So, like in the case of the MultiThreader stuff, we have three  
options:
(1) Remove the NumericTraits wrapping
(2) Remove the NumericTraits wrapping on windows
(3) Provide a hacked NumericTraits header for windows that doesn't  
have the offending static symbols, but does have the rest.

None of this is good, and in no case will windows users ever be able  
to access these static symbols until I (if I ever get a chance; no  
guarantees) look into getting a replacement for cableswig going.

A temporary option would be to look into the swig source files and  
find where all of those unresolved symbols are defined, and manually  
adding __declspec(dllimport) to them, like the proposed fix of adding  
__stdcall to the MultiThreader code.

Note: I will push a patch to Gaetan's repository soon which fixes (I  
hope) the MultiThreader issues. These might take a little longer.

Zach



On Feb 16, 2006, at 6:12 AM, Gaetan Lehmann wrote:

> On Thu, 16 Feb 2006 11:03:49 +0100, Charl P. Botha  
> <cpbotha at cpbotha.net> wrote:
>
>> Dear Zach and Gaetan,
>>
>> After manually adding __stdcall to all the right places in the
>> generated code, my WrapITK build now breaks at the _ITKCommonAPython
>> link phase with:
>>
>> _ITKCommonAPython error LNK2001: unresolved external symbol "public:
>> static class itk::CovariantVector<float,2> const
>> itk::NumericTraits<class itk::CovariantVector<float,2> >::Zero"
>> (?Zero@?$NumericTraits at V?$CovariantVector at M$01 at itk@@@itk@@2V? 
>> $CovariantVector at M$01 at 2@B)
>>
>> and two more times, for CovariantVector<float,3> and  
>> RGBPixel<unsigned char>.
>>
>> "Zero" (the unresolved symbol) is a static const variable of
>> NumericTraits with type == template type.  Looking at the
>> itkNumericTraits.cxx, "Zero" is initialised (outside of the class
>> declaration or definition, as all static member variables should be)
>> for all basic types (bool, unsigned char, float, double, etc.) but
>> obviously not for our template types (CovariantVector and RGBPixel).
>>
>
> Unless I'm completely wrong, Zero is declared in  
> itkNumericTraitsCovariantVectorPixel.h, and is  initialized in  
> itkNumericTraitsCovariantVectorPixel.cxx for type  
> CovariantVector<float,2>.
> This code should be in ITKCommon shared library.
> Can you give the command line of the linker ?
>
>> Could this be part of the build problem under VS.NET 2003?  For
>> CoviariantVector and RGBPixel, shouldn't NumericTraits::Zero be
>> initialized somewhere in the generated CXX code?
>>
>> Regards,
>> Charl
>
>
>
> -- 
> Gaëtan Lehmann
> Biologie du Développement et de la Reproduction
> INRA de Jouy-en-Josas (France)
> tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
> http://voxel.jouy.inra.fr
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users



More information about the Insight-users mailing list