[Insight-users] Compiling error (Linking error): ITK

Michael Bell michael.bell at acm.org
Thu Aug 3 22:12:26 EDT 2006


Amitesh,

This is a little bit confusing because your previous message shows an
error in line 279 of imageprocessing.cpp:
/home/amitesh/work/gui/imageprocessing.cpp:279: undefined reference to
`IntensityManipClass< unsigned short>::IntensityManipClass()', but the
file you sent has only 131 lines. I assume you have been debugging and
sent a more recent copy.

Either way, I believe the problem is that your IntensityManip class is
templated, so you should not compile it on it's own. It needs to be
compiled when the type is known. For example, you might have an
IntensityManipClass<int> and an IntensityManipClass<float>, so it
would actually need to be compiled twice, once for each type, inside
of the class that uses it (imageprocessing.cpp).

The easiest (but not the best style) way to do this is to put
IntensityManip.cpp inside of IntensityManip.h, and remove it from your
Makefile. This was probably just an oversight, but if you are not
familiar with templates, I suggest you experiment with this without
ITK in order to reduce the complexity of the code and the error
messages.

Please write if this does not solve your problem,
michael

On 8/3/06, Amitesh Agarwal <amiteshagarwal at gmail.com> wrote:
> Hello,
>
>  Please find the necessary cpp file, headerfile and makefile attached.
> Please let me know if the anymore information is needed.
>  Thanks
>
>  Amitesh
>
>
> On 8/3/06, Michael Bell <michael.bell at acm.org> wrote:
> > Amitesh,
> >
> > Please post your makefile and the header file for IntensityManip. It
> > appears that you are not
> > linking in a necessary class, or you have misnamed something, but it
> > is hard to tell without more information.
> >
> > michael
> > On 8/2/06, Amitesh Agarwal <amiteshagarwal at gmail.com> wrote:
> > > Hi All,
> > >
> > >  I am writing  a multifile  application using itk. The individual
> classes
> > > and files are sound syntaxically but there is a linking error which
> occurs
> > > after compiling individual files as shown below. I think the error lies
> in
> > > the Makefile that I am using. As I have not seen any example of
> Makefile, in
> > > ITK Examples or anywhere else,  which uses multiple files for creating
> an
> > > ITK application, I was wondering if anyone else is facing the same
> problem
> > > or if anyone has a solution to that. I hope to get a reply which solves
> my
> > > problems.
> > >
> > >  With Best Regards
> > >
> > >  Amitesh
> > >
> > >
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> > > [amitesh at mephisto gui]$ make
> > >  g++ imageprocessing.cpp
> > >  g++ OpenFile.cpp
> > >  g++ IntensityManip.cpp
> > >  Linking imageprocessing...
> > >
> imageprocessing.o(.gnu.linkonce.t._Z17ParameterfileReadItEvPiPdS1_Ss+0x7f2):
> > > In function `vo id ParameterfileRead<unsigned short>(int*, double*,
> double*,
> > > std::basic_string<char, std::ch ar_traits<char>, std::allocator<char>
> >)':
> > >  /home/amitesh/work/gui/imageprocessing.cpp:279:
> undefined
> > > reference to `IntensityManipClass< unsigned
> short>::IntensityManipClass()'
> > >
> imageprocessing.o(.gnu.linkonce.t._Z17ParameterfileReadItEvPiPdS1_Ss+0x857):
> > > In function `vo id ParameterfileRead<unsigned short>(int*, double*,
> double*,
> > > std::basic_string<char, std::ch ar_traits<char>, std::allocator<char>
> >)':
> > >
> /home/amitesh/.local/include/InsightToolkit/Common/itkSmartPointer.h:143:
> > > undefined referenc e to `IntensityManipClass<unsigned
> > > short>::RescaleFilterClass(unsigned short, unsigned
> short ,
> > > itk::SmartPointer<itk::Image<unsigned short, 3u> >)'
> > >
> imageprocessing.o(.gnu.linkonce.t._Z17ParameterfileReadItEvPiPdS1_Ss+0x8d7):/home/amitesh/.l
> > >
> ocal/include/InsightToolkit/Common/itkSmartPointer.h:143:
> > > undefined reference to `IntensityM anipClass<unsigned
> > > short>::ShiftFilterClass(unsigned short, double,
> > > itk::SmartPointer<itk::I mage<unsigned short, 3u> >)'
> > >
> imageprocessing.o(.gnu.linkonce.t._Z17ParameterfileReadItEvPiPdS1_Ss+0x935):/home/amitesh/.l
> > >
> ocal/include/InsightToolkit/Common/itkSmartPointer.h:143:
> > > undefined reference to `IntensityM anipClass<unsigned
> > >
> short>::NormalizeFilterClass(itk::SmartPointer<itk::Image<unsigned
> > > short,  3u> >)'
> > >
> imageprocessing.o(.gnu.linkonce.t._Z17ParameterfileReadItEvPiPdS1_Ss+0x993):/home/amitesh/.l
> > >
> ocal/include/InsightToolkit/Common/itkSmartPointer.h:143:
> > > undefined reference to `IntensityM anipClass<unsigned
> > >
> short>::NegativeFilterClass(itk::SmartPointer<itk::Image<unsigned
> > > short, 3u> >)'
> > >
> imageprocessing.o(.gnu.linkonce.t._Z17ParameterfileReadIfEvPiPdS1_Ss+0x7f7):
> > > In function `vo id ParameterfileRead<float>(int*, double*, double*,
> > > std::basic_string<char, std::char_traits <char>, std::allocator<char>
> >)':
> > >  /home/amitesh/work/gui/imageprocessing.cpp:279:
> undefined
> > > reference to `IntensityManipClass< float>::IntensityManipClass()'
> > >
> imageprocessing.o(.gnu.linkonce.t._Z17ParameterfileReadIfEvPiPdS1_Ss+0x85e):
> > > In function `vo id ParameterfileRead<float>(int*, double*, double*,
> > > std::basic_string<char, std::char_traits <char>, std::allocator<char>
> >)':
> > >
> /home/amitesh/.local/include/InsightToolkit/Common/itkSmartPointer.h:143:
> > > undefined referenc e to
> > > `IntensityManipClass<float>::RescaleFilterClass(float,
> > > float, itk::SmartPointer<itk::Im age<float, 3u> >)'
> > >
> imageprocessing.o(.gnu.linkonce.t._Z17ParameterfileReadIfEvPiPdS1_Ss+0x8e2):/home/amitesh/.l
> > >
> ocal/include/InsightToolkit/Common/itkSmartPointer.h:143:
> > > undefined reference to `IntensityM
> > > anipClass<float>::ShiftFilterClass(float, double,
> > > itk::SmartPointer<itk::Image<float, 3u> >) '
> > >
> imageprocessing.o(.gnu.linkonce.t._Z17ParameterfileReadIfEvPiPdS1_Ss+0x940):/home/amitesh/.l
> > >
> ocal/include/InsightToolkit/Common/itkSmartPointer.h:143:
> > > undefined reference to `IntensityM
> > >
> anipClass<float>::NormalizeFilterClass(itk::SmartPointer<itk::Image<float,
> > > 3u> >)'
> > >
> imageprocessing.o(.gnu.linkonce.t._Z17ParameterfileReadIfEvPiPdS1_Ss+0x99e):/home/amitesh/.l
> > >
> ocal/include/InsightToolkit/Common/itkSmartPointer.h:143:
> > > undefined reference to `IntensityM
> > >
> anipClass<float>::NegativeFilterClass(itk::SmartPointer<itk::Image<float,
> > > 3u> >)'
> > >
> imageprocessing.o(.gnu.linkonce.t._Z17ParameterfileReadIhEvPiPdS1_Ss+0x7f2):
> > > In function `vo id ParameterfileRead<unsigned char>(int*, double*,
> double*,
> > > std::basic_string<char, std::cha r_traits<char>, std::allocator<char>
> >)':
> > >  /home/amitesh/work/gui/imageprocessing.cpp:279:
> undefined
> > > reference to `IntensityManipClass< unsigned
> char>::IntensityManipClass()'
> > >
> imageprocessing.o(.gnu.linkonce.t._Z17ParameterfileReadIhEvPiPdS1_Ss+0x857):
> > > In function `vo id ParameterfileRead<unsigned char>(int*, double*,
> double*,
> > > std::basic_string<char, std::cha r_traits<char>, std::allocator<char>
> >)':
> > >
> /home/amitesh/.local/include/InsightToolkit/Common/itkSmartPointer.h:143:
> > > undefined referenc e to `IntensityManipClass<unsigned
> > > char>::RescaleFilterClass(unsigned char, unsigned char,
> i
> > > tk::SmartPointer<itk::Image<unsigned char, 3u> >)'
> > > imageprocessing.o
> (.gnu.linkonce.t._Z17ParameterfileReadIhEvPiPdS1_Ss+0x8d7):/home/amitesh/.l
> > >
> ocal/include/InsightToolkit/Common/itkSmartPointer.h:143:
> > > undefined reference to `IntensityM anipClass<unsigned
> > > char>::ShiftFilterClass(unsigned char, double,
> > > itk::SmartPointer<itk::Ima ge<unsigned char, 3u> >)'
> > >
> imageprocessing.o(.gnu.linkonce.t._Z17ParameterfileReadIhEvPiPdS1_Ss+0x935):/home/amitesh/.l
> > >
> ocal/include/InsightToolkit/Common/itkSmartPointer.h:143:
> > > undefined reference to `IntensityM anipClass<unsigned
> > >
> char>::NormalizeFilterClass(itk::SmartPointer<itk::Image<unsigned
> > > char, 3 u> >)'
> > >
> imageprocessing.o(.gnu.linkonce.t._Z17ParameterfileReadIhEvPiPdS1_Ss+0x993):/home/amitesh/.l
> > >
> ocal/include/InsightToolkit/Common/itkSmartPointer.h:143:
> > > undefined reference to `IntensityM anipClass<unsigned
> > >
> char>::NegativeFilterClass(itk::SmartPointer<itk::Image<unsigned
> > > char, 3u > >)'
> > >  collect2: ld returned 1 exit status
> > >  make: *** [imageprocessing] Error 1
> > >
> > >
> > > _______________________________________________
> > > Insight-users mailing list
> > > Insight-users at itk.org
> > > http://www.itk.org/mailman/listinfo/insight-users
> > >
> > >
> > >
> >
> >
> > --
> > michael.bell at acm.org
> >
>
>
>


-- 
michael.bell at acm.org


More information about the Insight-users mailing list