[Insight-users] Link-problems with my own itk-filter

Luis Ibanez luis . ibanez at kitware . com
Thu, 04 Dec 2003 12:20:40 -0500


Hi Corinne,

1) About the ITK namespace
    You don't need to put your new filter in the 'itk' namespace.
    You can do it if you will, but it is not a requisite.
    The compiler errors that you are getting when you don't put
    your filter in the ITK namespace are probably due to the use
    of ITK types, like Image<>, ImageRegion, Size... etc.  If your
    filter is inside the itk namespace you are allowed to refer to
    ITK types without having to add the itk:: namespace scope, but
    when your filter is not in the itk namespace then you must preceed
    any ITK type with the itk:: namespace specification.

    Of course it will be easier for us to tell if you post the
    error compiler messages   :-)


2) The link errors for the constructor indicates that you are not
    defining the constructor, just declaring it.  You can do something
    as simple as

    protected:
      myFilter()  {}   // constructor
     ~myFilter()  {}   // destructor


    but again,
     it will be easier to help you if you post the
     header file of your filter.



Regards,


    Luis


---------------------------
Corinne Mattmann wrote:

> Hi,
> 
> I want to create my own itk-filter but I have some problems making it
> work!
> I use Microsoft Visual C++ and I include the files (my txx- and h-file
> from the filter and a testfile where I create an instance of my filter)
> in my project with CMake:
> ADD_EXECUTABLE(TestDeformableRegistrationFilter
> TestDeformableRegistrationFilter.cxx
> 		DeformableRegistrationFilter.txx
> DeformableRegistrationFilter.h)
> My filter is inherited from the ImageToImageFilter:
>   	template < class TInputImage1, class TInputImage2, class
> TOutputImage >
>   	class ITK_EXPORT DeformableRegistrationFilter : public
> ImageToImageFilter<TInputImage1,TOutputImage> 
> and I put everything in the "namespace itk".
> 
> Now my problems:
> 
> - If I compile my test-project (TestDeformableRegistrationFilter) it
> doesn't report me any errors in my filter-files. But if I take out the
> "namespace itk" I get compile errors. Why does my compiler not work
> properly if I use "namespace itk"?
> 
> - The second problem is that (independent of using the namespace itk or
> not) after compiling without errors, my project doesn't link. I guess it
> can't find my protected Constructor (I use public: itkNewMacro(Self) in
> my h-file). What am I doing wrong?
> Here's the error I get:
> Linking...
>    Creating library
> D:\packwin\vtkMy\bin\bin\Debug/TestDeformableRegistrationFilter.lib and
> object
> D:\packwin\vtkMy\bin\bin\Debug/TestDeformableRegistrationFilter.exp
> TestDeformableRegistrationFilter.obj : error LNK2001: unresolved
> external symbol "protected: __thiscall
> itk::DeformableRegistrationFilter<class itk::Image<char,3>,class
> itk::Image<char,3>,class itk::Image<class itk::Vector<float,3>,3>
> 
>>::DeformableRegistrationFilter<class itk::Image<char,3>,class
> 
> itk::Image<char,3>,class itk::Image<class itk::Vector<float,3>,3>
> 
>>(void)"
> 
> (??0?$DeformableRegistrationFilter at V?$Image at D$02 at itk@@V12 at V?$Image at V?$Ve
> ctor at M$02 at itk@@$02 at 2@@itk@@IAE at XZ)
> D:\packwin\vtkMy\bin\bin\Debug/TestDeformableRegistrationFilter.exe :
> fatal error LNK1120: 1 unresolved externals
> Error executing link.exe.
> 
> Can anybody help me?
> Thanks very much,
> Corinne Mattmann
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users
>