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

Corinne Mattmann mattmaco at ee . ethz . ch
Thu, 4 Dec 2003 11:41:07 -0700


Hi Luis,

Thanks very much for your fast reply.
I just found my mistake: I forgot to include the txx-file in the h-file
(#include "DeformableRegistrationFilter.txx"). That's why it did't
report me the errors in the txx-file and why it couldn't find the
constructor (your hint with defining the constructor in the h-file
helped me). Everything is clear now ;-).

Thanks,
Corinne


-----Original Message-----
From: Luis Ibanez [mailto:luis . ibanez at kitware . com] 
Sent: Thursday, December 04, 2003 10:21 AM
To: Corinne Mattmann
Cc: insight-users at itk . org
Subject: Re: [Insight-users] Link-problems with my own itk-filter



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
>