[ITK] Compilation errors

Cory Quammen cory.quammen at kitware.com
Wed Jun 4 08:49:12 EDT 2014


Ruturaj,

All classes and data structures in ITK are in the itk namespace. Including
a line with "using namespace itk" should solve your immediate problems, but
is a discouraged practice (see, for example,
http://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice
).

Instead, it is usual practice to change all class and data structure names
to include the itk namespace qualifier. For example, in your code, you
should change

ReaderType::Pointer reader = ReaderType::New();

to

itk::ReaderType::Pointer reader = itk::ReaderType::New();

MedianFilterType::Pointer medianfilter = MedianFilterType::New();

to

itk::MedianFilterType::Pointer medianfilter = itk::MedianFilterType::New();

and so on.

Hope that helps,
Cory


On Wed, Jun 4, 2014 at 8:39 AM, Girish, Gavaskar Ruturaj <
gavaskar.ruturaj.girish at philips.com> wrote:

> Dear Bill,
> Here I have copied a small program which gives the same errors:
>
> #include        "Filter_Type_Definitions.h"
> int main( int argc, char *argv[])
> {
>         ReaderType::Pointer reader = ReaderType::New();
>         reader->SetFileName( argv[1] );
>         reader->Update();
>
>         //Apply a median filter
>         MedianFilterType::Pointer medianfilter = MedianFilterType::New();
>         GrayscaleImageType::SizeType indexradius;
>         indexradius[0] = 3;             //X radius
>         indexradius[1] = 3;             //Y radius
>         indexradius[2] = 3;             //Z radius
>         medianfilter->SetRadius( indexradius );
>         medianfilter->SetInput( input_image );
>         medianfilter->Update();
>
> }
>
> Now, I have used only itkMedianImageFilter in this example, but in my
> actual code I am using many more filters. Hence I have kept the file
> Filter_Type_Definitions.h as it is without deleting the extra filters, in
> case they are of any help. I have attached the file with this post. I had
> written many programs before today in which I had included all the headers
> in the main source code file, and they all compiled without errors. It was
> only when I kept the headers and typedef's in a separate file that the
> errors began occurring.
>
> Thanks & Regards,
> Ruturaj
>
> -----Original Message-----
> From: Bill Lorensen [mailto:bill.lorensen at gmail.com]
> Sent: Wednesday, June 04, 2014 5:41 PM
> To: Girish, Gavaskar Ruturaj
> Cc: community at itk.org
> Subject: Re: [ITK] Compilation errors
>
> Please post a small, complete program that illustrates the problem.
>
>
> On Wed, Jun 4, 2014 at 7:58 AM, Girish, Gavaskar Ruturaj <
> gavaskar.ruturaj.girish at philips.com> wrote:
> > Dear all,
> >
> >
> >
> > I have written an ITK program which gives me errors when I try to
> > compile it. I have copied a small sample of the errors below. All the
> > other errors are similar.
> >
> >
> >
> > c:\program files\itk\include\itk-4.6\itkImageSource.h(108): error C2039:
> > 'RegionType' : is not a member of '`global namespace''
> >
> > 2>c:\program files\itk\include\itk-4.6\itkImageSource.h(108): error
> C2146:
> > syntax error : missing ';' before identifier 'OutputImageRegionType'
> >
> > 2>c:\program files\itk\include\itk-4.6\itkImageSource.h(108): error
> C4430:
> > missing type specifier - int assumed. Note: C++ does not support
> > default-int
> >
> > 2>c:\program files\itk\include\itk-4.6\itkImageSource.h(109): error
> C2825:
> > 'itk::ImageSource<TOutputImage>::OutputImageType': must be a class or
> > namespace when followed by '::'
> >
> >
> >
> > c:\program files\itk\include\itk-4.6\itkImageSource.h(109): error C2039:
> > 'PixelType' : is not a member of '`global namespace''
> >
> > 2>c:\program files\itk\include\itk-4.6\itkImageSource.h(109): error
> C2146:
> > syntax error : missing ';' before identifier 'OutputImagePixelType'
> >
> > 2>c:\program files\itk\include\itk-4.6\itkImageSource.h(109): error
> C4430:
> > missing type specifier - int assumed. Note: C++ does not support
> > default-int
> >
> > 2>c:\program files\itk\include\itk-4.6\itkImageSource.h(112): error
> C2825:
> > 'TOutputImage': must be a class or namespace when followed by '::'
> >
> > 2>c:\program files\itk\include\itk-4.6\itkImageSource.h(112): error
> C2039:
> > 'ImageDimension' : is not a member of '`global namespace''
> >
> > 2>c:\program files\itk\include\itk-4.6\itkImageSource.h(112): error
> C2275:
> > 'TOutputImage' : illegal use of this type as an expression
> >
> > 2>          c:\program
> > files\itk\include\itk-4.6\itkImageToImageFilter.h(103) : see
> > declaration of 'TOutputImage'
> >
> > 2>c:\program files\itk\include\itk-4.6\itkImageSource.h(112): error
> C2146:
> > syntax error : missing '}' before identifier 'ImageDimension'
> >
> > 2>c:\program files\itk\include\itk-4.6\itkImageSource.h(112): error
> C2143:
> > syntax error : missing ';' before '}'
> >
> > 2>c:\program files\itk\include\itk-4.6\itkImageToImageFilter.h(115):
> > 2>error
> > C2039: 'OutputImageRegionType' : is not a member of
> > 'itk::ImageSource<TOutputImage>'
> >
> >
> >
> > When I searched on google, I found that this might happen if header
> > files are included in the ‘wrong’ order. If it helps, I have included
> > them in the following order:
> >
> > #include               <iostream>
> >
> > #include               "itkImage.h"
> >
> > #include               "itkPoint.h"
> >
> > #include               "itkIndex.h"
> >
> > #include               "itkImageFileReader.h"
> >
> > #include               "itkImageFileWriter.h"
> >
> > #include               "itkMedianImageFilter.h"
> >
> > #include               "itkThresholdImageFilter.h"
> >
> > #include               "itkBinaryThresholdImageFilter.h"
> >
> > #include               "itkBinaryFillholeImageFilter.h"
> >
> > #include               "itkMaskImageFilter.h"
> >
> > #include               "itkOtsuThresholdImageFilter.h"
> >
> > #include               "itkAndImageFilter.h"
> >
> > #include               "itkBinaryShapeOpeningImageFilter.h"
> >
> > #include               "itkBinaryShapeKeepNObjectsImageFilter.h"
> >
> > #include               "itkXorImageFilter.h"
> >
> > #include               "itkConnectedComponentImageFilter.h"
> >
> > #include               "itkLabelGeometryImageFilter.h"
> >
> >
> >
> > I have created a separate header file in which I have included all the
> > above header files and also all the typedef’s for the filters. Can
> > anybody give me an idea to why such errors may be occurring? I have
> > not used a ‘using namespace xxxx’ anywhere.
> >
> >
> >
> > Thanks & Regards,
> >
> > Ruturaj
> >
> >
> > ________________________________
> > The information contained in this message may be confidential and
> > legally protected under applicable law. The message is intended solely
> > for the addressee(s). If you are not the intended recipient, you are
> > hereby notified that any use, forwarding, dissemination, or
> > reproduction of this message is strictly prohibited and may be
> > unlawful. If you are not the intended recipient, please contact the
> > sender by return e-mail and destroy all copies of the original message.
> >
> > _______________________________________________
> > Community mailing list
> > Community at itk.org
> > http://public.kitware.com/cgi-bin/mailman/listinfo/community
> >
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com
>
> ________________________________
> The information contained in this message may be confidential and legally
> protected under applicable law. The message is intended solely for the
> addressee(s). If you are not the intended recipient, you are hereby
> notified that any use, forwarding, dissemination, or reproduction of this
> message is strictly prohibited and may be unlawful. If you are not the
> intended recipient, please contact the sender by return e-mail and destroy
> all copies of the original message.
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/cgi-bin/mailman/listinfo/community
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140604/cd7b9734/attachment-0002.html>


More information about the Community mailing list