[Insight-users] GettingStarted-II compilation problem
Luis Ibanez
luis.ibanez at kitware.com
Tue, 03 Feb 2004 13:14:59 -0500
Hi David,
You are mixing a recent version of "Insight"
with an older version of "InsightApplications"
The filter itkVTKImageExport recently got an
extra template parameter in order to accomodate
for changes in the API of VTK - CVS.
The changes were made also in InsightApplications
on January 16 2004. Please synchronize your
checkouts.
Easy options are:
A) CVS update InsightApplications
OR
B) Use ITK 1.6 for both Insight and InsightApplications.
Remember that whenever you cvs update Insight you
must also cvs update InsightApplications.
--------------
Also, please don't use qmake.
You can use CMake in order to build projects
involving Qt.
Please look at the directories:
InsightApplications/QtITK
and
InsightApplications/Auxiliary/QtImageViewer
for examples on how to setup a CMakeLists.txt
project.
Regards,
Luis
------------------------------
David Macias Verde wrote:
> Thanks for your answer. I've worked hard with what you suggested but I
> don't get a solution. Maybe it's because I am new to all this things
> (VTK,ITK and Qt). I have some experience but not enough to get through
> this.
>
> I am putting all the includes and libraries, although they are not
> needed to my project. The fact is that when I include the lines with
> ImageToVTKImageFilter, my code is not compiled. If they are deleted all
> is working fine. I do not know how to fix the error I have with
> ImageToVTKImageFilter.
>
> Here it is my project file. I am using qmake to do the Makefile, because
> I am working with Qt.
>
> -----------------------------------------------------------------------
> TEMPLATE = app
> CONFIG = qt warn_on release
> LIBS = -L/usr/local/VTK-4.2.1/bin -lvtkCommon -lvtkFiltering
> -lvtkGraphics -lvtkHybrid -lvtkIO -lvtkImaging -lvtkParallel
> -lvtkPatented -lvtkRendering -lvtkjpeg -lvtkpng -lvtkzlib -lvtktiff
> LIBS += -L/usr/local/lib/InsightToolkit -lITKNumerics -lITKIO
> -lITKCommon -lVXLNumerics -litkpng -litkzlib -lITKMetaIO
> -lITKDICOMParser
> INCLUDEPATH = /usr/local/VTK-4.2.1/Include
> INCLUDEPATH += /usr/local/include/InsightToolkit/
> INCLUDEPATH += /usr/local/include/InsightToolkit/Numerics
> INCLUDEPATH += /usr/local/include/InsightToolkit/Numerics/vxl
> INCLUDEPATH += /usr/local/include/InsightToolkit/Numerics/vxl/vnl
> INCLUDEPATH += /usr/local/include/InsightToolkit/Numerics/vxl/vcl
> INCLUDEPATH += /usr/local/include/InsightToolkit/Numerics/FEM
> INCLUDEPATH += /usr/local/include/InsightToolkit/Numerics/Statistics
> INCLUDEPATH += /usr/local/include/InsightToolkit/Algorithms
> INCLUDEPATH += /usr/local/include/InsightToolkit/BasicFilters
> INCLUDEPATH += /usr/local/include/InsightToolkit/Common
> INCLUDEPATH += /usr/local/include/InsightToolkit/IO
> INCLUDEPATH += /usr/local/include/InsightToolkit/SpatialObject
> INCLUDEPATH += /usr/local/include/InsightToolkit/Utilities/zlib
> INCLUDEPATH += /usr/local/include/InsightToolkit/Utilities/png
> INCLUDEPATH += /usr/local/include/InsightToolkit/Utilities/MetaIO
> INCLUDEPATH += /usr/local/include/InsightToolkit/MetaIO/SpatialObject
> INCLUDEPATH += /usr/local/include/InsightToolkit/Utilities/DICOMParser
> INCLUDEPATH += /usr/local/InsightApplications-1.6.0/Auxiliary/vtk
> DESTDIR =
> HEADERS =
> SOURCES = prueba.cxx
> INTERFACES =
> TARGET = prueba
> -------------------------------------------------------------------------
>
> Above you could see all the LIBS and INCLUDES I'm using to compile.
> The code I want you to ask why it is not compiling is the following:
>
> -------------------------------------------------------------------------
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkImageToVTKImageFilter.h"
>
> #include "vtkImageViewer.h"
> #include "vtkRenderWindowInteractor.h"
>
> int main()
> {
>
> typedef itk::Image <unsigned short,2> ImageType;
> typedef itk::ImageFileReader <ImageType> ReaderType;
> typedef itk::ImageToVTKImageFilter<ImageType> ConnectorType;
>
> ReaderType::Pointer reader = ReaderType::New();
> reader->SetFileName("./circle.png");
>
> ConnectorType::Pointer connector = ConnectorType::New();
> connector->SetInput( reader->GetOutput() );
>
> vtkRenderWindowInteractor *renderWindowInteractor =
> vtkRenderWindowInteractor::New();
>
> vtkImageViewer *viewer = vtkImageViewer::New();
> viewer->SetInput( connector->GetOutput() );
> viewer->SetColorWindow( 255 );
> viewer->SetColorLevel( 128 );
> viewer->SetupInteractor( renderWindowInteractor );
>
> viewer->Render();
> renderWindowInteractor->Start();
>
> return 0;
> }
> ---------------------------------------------------------------------------
>
> The error messages are these ones:
>
> ----------------------------------------------------------------------------
> In file included from prueba.cxx:3:
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.h:61: error: wrong
> number of template arguments (2, should be 1)
> /usr/local/include/InsightToolkit/BasicFilters/itkVTKImageExport.h:52:
> error: provided
> for `template<class TInputImage> class itk::VTKImageExport'
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.h:61: error: ISO
> C++ forbids declaration of `ExporterFilterType' with no type
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.h:62: error: no
> type named `Pointer' in `int'
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.h:62: error: ISO
> C++ forbids declaration of `ExporterFilterPointer' with no type
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx: In
> member function `void
> itk::ImageToVTKImageFilter<TInputImage>::SetInput(const TInputImage*)
> [with
> TInputImage = main()::ImageType]':
> prueba.cxx:19: instantiated from here
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx:76: error: base
> operand of `->' is not a pointer
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx: In
> constructor `
> itk::ImageToVTKImageFilter<TInputImage>::ImageToVTKImageFilter()
> [with
> TInputImage = main()::ImageType]':
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.h:53: instantiated from `static itk::SmartPointer<itk::ImageToVTKImageFilter<TInputImage> > itk::ImageToVTKImageFilter<TInputImage>::New() [with TInputImage = main()::ImageType]'
> prueba.cxx:18: instantiated from here
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx:37: error: `
> int' is not a class type
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx:39: error: base
> operand of `->' is not a pointer
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx:40: error: base
> operand of `->' is not a pointer
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx:41: error: base
> operand of `->' is not a pointer
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx:42: error: base
> operand of `->' is not a pointer
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx:43: error: base
> operand of `->' is not a pointer
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx:44: error: base
> operand of `->' is not a pointer
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx:45: error: base
> operand of `->' is not a pointer
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx:46: error: base
> operand of `->' is not a pointer
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx:47: error: base
> operand of `->' is not a pointer
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx:48: error: base
> operand of `->' is not a pointer
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx:49: error: base
> operand of `->' is not a pointer
> /usr/local/InsightApplications-1.6.0/Auxiliary/vtk/itkImageToVTKImageFilter.txx:50: error: base
> operand of `->' is not a pointer
> make: *** [prueba.o] Error 1
>
> -------------------------------------------------------------------------
>
> If I exclude the lines related with itkImageToVTKImageFilter.h it works:
>
> ----------------------------------------------------------------------
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> //#include "itkImageToVTKImageFilter.h"
>
> #include "vtkImageViewer.h"
> #include "vtkRenderWindowInteractor.h"
>
> int main()
> {
>
> typedef itk::Image <unsigned short,2> ImageType;
> typedef itk::ImageFileReader <ImageType> ReaderType;
> //typedef itk::ImageToVTKImageFilter<ImageType> ConnectorType;
>
> ReaderType::Pointer reader = ReaderType::New();
> reader->SetFileName("./circle.png");
>
> //ConnectorType::Pointer connector = ConnectorType::New();
> //connector->SetInput( reader->GetOutput() );
>
> vtkRenderWindowInteractor *renderWindowInteractor =
> vtkRenderWindowInteractor::New();
>
> vtkImageViewer *viewer = vtkImageViewer::New();
> //viewer->SetInput( connector->GetOutput() );
> viewer->SetColorWindow( 255 );
> viewer->SetColorLevel( 128 );
> viewer->SetupInteractor( renderWindowInteractor );
>
> viewer->Render();
> renderWindowInteractor->Start();
>
> return 0;
> }
> -------------------------------------------------------------
>
> Thanks in advance
>
> David Macias
>
> On Thu, 2004-01-29 at 14:20, Luis Ibanez wrote:
>
>>Hi David,
>>
>>The error messages indicate that the
>>compiler have not found the declaration
>>of the class ImageToVTKImage.
>>
>>Didn't you get a message saying that the
>>header file "itkImageToVTKImageFilter.h"
>>wasn't found ?
>>
>>This is the typical cause for these errors.
>>
>>In order to compile this example, the
>>simplest thing to do is to copy the
>>files
>>
>> itkImageToVTKImageFilter.h
>> itkImageToVTKImageFilter.txx
>>
>>in the same directory where your .cxx
>>file is. These files are available at
>>
>> InsightApplications/Auxiliary/vtk
>>
>>The reason why these files are not
>>along with the basic source tree of
>>ITK is that they are a bridge between
>>ITK and VTK. Putting these files into
>>ITK will create an artificial dependendy
>>between ITK and VTK.
>>
>>Please let us know if you still find
>>any problems after copying these files
>>into your directory.
>>
>>
>>Thanks
>>
>>
>> Luis
>>
>>
>>
>>------------------
>>
>>David Macias Verde wrote:
>>
>>
>>>Hi all:
>>>
>>>I am new to itk and I have a very elemental question. When compiling the
>>>source coming in the GettingStarted-II presentation
>>>(/InsightDocuments/CourseWare/Training/
>>><http://www.itk.org/cgi-bin/cvsweb.cgi/InsightDocuments/CourseWare/Training/GettingStarted-V.ppt?cvsroot=Insight>),
>>>which is
>>>
>>>#include "itkImage.h"
>>>#include "itkImageFileReader.h"
>>>#include "itkImageToVTKImageFilter.h"
>>>
>>>#include "vtkImageViewer.h"
>>>#include "vtkRenderWindowInteractor.h"
>>>
>>>int main( int argc, char **argv ) {
>>>
>>> typedef itk::Image <unsigned short,2> ImageType;
>>> typedef itk::ImageFileReader <ImageType> ReaderType;
>>> typedef itk::ImageToVTKImageFilter <ImageType> ConnectorType;
>>>
>>> ReaderType::Pointer reader = ReaderType::New();
>>> ConnectorType::Pointer connector = ConnectorType::New();
>>>
>>> reader->SetFileName( argv[1] );
>>> connector->SetInput( reader->GetOutput() );
>>>
>>> vtkImageViewer * viewer = vtkImageViewer::New();
>>>
>>> vtkRenderWindowInteractor * renderWindowInteractor =
>>>vtkRenderWindowInteractor::New();
>>>
>>> viewer->SetupInteractor( renderWindowInteractor );
>>> viewer->SetInput( connector->GetOutput() );
>>>
>>> viewer->Render();
>>> viewer->SetColorWindow( 255 );
>>> viewer->SetColorLevel( 128 );
>>> renderWindowInteractor->Start();
>>>
>>> return 0;
>>>}
>>>
>>>I get the following message.
>>>
>>>prueba.cxx: In function `int main(int, char**)':
>>>prueba.cxx:12: error: ISO C++ forbids declaration of `ImageToVTKImageFilter'
>>> with no type
>>>prueba.cxx:12: error: template-id `ImageToVTKImageFilter<main(int,
>>> char**)::ImageType>' used as a declarator
>>>prueba.cxx:12: error: syntax error before `;' token
>>>prueba.cxx:15: error: `ConnectorType' undeclared (first use this function)
>>>prueba.cxx:15: error: (Each undeclared identifier is reported only once for
>>> each function it appears in.)
>>>prueba.cxx:15: error: syntax error before `::' token
>>>prueba.cxx:18: error: `connector' undeclared (first use this function)
>>>prueba.cxx:8: warning: unused parameter `int argc'
>>>make: *** [prueba.o] Error 1
>>>
>>>I think I have all the libraries and includes right directed. May
>>>someone please give me a hand?
>>>
>>>Cheers,
>>>--
>>>David Macias Verde <_david.maciasverde at gobiernodecanarias.org_
>>><mailto:david.maciasverde at gobiernodecanarias.org>>
>>>Servicio de Física Médica - Hospital de Gran Canaria Dr. Negrín
>>>
>>>
>>>
>>
>>
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk.org
>>http://www.itk.org/mailman/listinfo/insight-users