[Insight-users] compilation error on linux

Reinhard Hameeteman reinhard.afstuderen at gmail.com
Tue Oct 11 11:06:20 EDT 2005


Thanks a lot,

Karthik, your modification did the trick.

Reinhard


2005/10/11, Karthik Krishnan <Karthik.Krishnan at kitware.com>:
> There are a few differences between gcc34 and 33 and code compiling on
> gcc34 will not necessarily compile on 33.
> One of the differences is accessing in class static members without
> using Self as a trait.
>
> ie, you have a typedef
>
>  typedef itk::BSplineDeformableTransform
>              < double, ImageDimension, 3 >    TransformType;
>
> which should instead read:
>
>  typedef itk::BSplineDeformableTransform
>              < double, itkGetStaticConstMacro(ImageDimension), 3 >
> TransformType;
>
> Regards
> karthik
>
>
> Andinet Enquobahrie wrote:
>
> > Hello Reinhard,
> >
> > I compiled your code in
> >
> > Linux gcc  3.4.3
> > ITK - cvs version
> > GNU make - 3.8
> >
> > it compiles with no errors....
> >
> > -Andinet
> >
> >
> > I tried to reproduce the problem in your code
> >
> >> Hi,
> >>
> >> I am making an application to do deformable liver registrations. The
> >> program I made so far works fine on a windows machine using the VC++
> >> 6.0 compiler. But now I want to move the program to a linux machine
> >> and refuses to compile using
> >> gcc 3.3.5 and make 3.8. The error is in a templated class which I
> >> wrote. In my program I perform a rigid registration which final
> >> parameters (3 translation parameters) I use to initialize the non
> >> rigid registration. My nonrigidregistration class has a member
> >> m_RigidTransformParameters which stores these parameters.
> >> The member function SetRigidTransform causes the following
> >> compilation error:
> >>
> >> /home/rhameeteman/source/test2/NonRigidRegistration.txx:105: error:
> >> prototype
> >>   for `void NonRigidRegistration<TFixedImage, TMovingImage,
> >>   TOutputImage>::SetRigidTransform(typename
> >>   itk::BSplineDeformableTransform<double,
> >> NonRigidRegistration<TFixedImage,
> >>   TMovingImage, TOutputImage>::ImageDimension, 3>::ParametersType)'
> >> does not
> >>   match any in class `NonRigidRegistration<TFixedImage, TMovingImage,
> >>   TOutputImage>'
> >> /home/rhameeteman/source/test2/NonRigidRegistration.h:209: error:
> >> candidate is:
> >>   void NonRigidRegistration<TFixedImage, TMovingImage,
> >>   TOutputImage>::SetRigidTransform(typename
> >>   itk::BSplineDeformableTransform<double,
> >> NonRigidRegistration<TFixedImage,
> >>   TMovingImage, TOutputImage>::ImageDimension, 3>::ParametersType)
> >> /home/rhameeteman/source/test2/NonRigidRegistration.txx:105: error:
> >> template
> >>   definition of non-template `void NonRigidRegistration<TFixedImage,
> >>   TMovingImage, TOutputImage>::SetRigidTransform(typename
> >>   itk::BSplineDeformableTransform<double,
> >> NonRigidRegistration<TFixedImage,
> >>   TMovingImage, TOutputImage>::ImageDimension, 3>::ParametersType)'
> >> make[1]: *** [LivReg.o] Error 1
> >> make: *** [default_target] Error 2
> >>
> >> What puzzles me is that the suggested candidate is exactly the same as
> >> the one causing the error.
> >> I included a sort of minimal example to demonstrate the problem. It
> >> compiles fine in VC, but won't build on Linux.
> >> I use itk 2.2.0
> >>
> >> Reinhard
> >>
> >>
> >> ------------------------------------------------------------------------
> >>
> >> PROJECT(LivReg)
> >>
> >> FIND_PACKAGE(ITK)
> >> IF(ITK_FOUND)
> >>  INCLUDE(${ITK_USE_FILE})
> >> ELSE(ITK_FOUND)
> >>  MESSAGE(FATAL_ERROR "ITK niet gevonden")
> >> ENDIF(ITK_FOUND)
> >>
> >>
> >> ADD_EXECUTABLE(
> >> LivReg                          LivReg.cpp
> >> NonRigidRegistration.txx        NonRigidRegistration.h)
> >>
> >>
> >> TARGET_LINK_LIBRARIES(LivReg ITKNumerics ITKIO ITKAlgorithms
> >> ITKBasicFilters ITKStatistics)
> >>
> >>
> >> ------------------------------------------------------------------------
> >>
> >> #include <stdio.h>
> >> #include "NonRigidRegistration.h"
> >>
> >> int main(int argc, char * argv[])
> >> {
> >>  std::cout << "startup: Image Registration Application" << std::endl;
> >>
> >>  char *parameterFile;
> >>
> >>  if (argc < 2 )
> >>  {
> >>    std::cout << "No filename provided, trying LiverRegistration.txt"
> >> << std::endl;
> >>    parameterFile = "LiverRegistration.txt";
> >>  }
> >>  else
> >>  {
> >>    parameterFile = argv[1];
> >>  }
> >>
> >>  const unsigned int ImageDimension = 3 ;
> >>  typedef unsigned char PixelType;
> >>
> >>  typedef itk::Image<PixelType, ImageDimension>
> >> InputImageType;
> >>  typedef itk::Image<PixelType, ImageDimension>
> >> OutputImageType;
> >>
> >>  typedef      NonRigidRegistration< InputImageType,
> >>                                     InputImageType,
> >>                                     OutputImageType >
> >> NonRigidRegistrationType;
> >>
> >>  NonRigidRegistrationType::Pointer  m_NonRigidRegistration;
> >>
> >>  m_NonRigidRegistration = NonRigidRegistrationType::New();
> >>
> >>
> >>  return 0;
> >> }
> >>
> >>
> >>
> >> ------------------------------------------------------------------------
> >>
> >> #ifndef _NONRIGIDREGISTRATION_H_
> >> #define _NONRIGIDREGISTRATION_H_
> >>
> >> #include "itkBSplineDeformableTransform.h"
> >> #include "itkImageToImageFilter.h"
> >>
> >>
> >>
> >> template <typename TFixedImage, typename TMovingImage, typename
> >> TOutputImage>
> >> class NonRigidRegistration : public
> >> itk::ImageToImageFilter<TMovingImage, TOutputImage>
> >> {
> >> public:
> >>
> >>  // Standard class typedefs.  typedef NonRigidRegistration  Self;
> >>  typedef itk::ImageToImageFilter<TMovingImage, TOutputImage>
> >> Superclass;
> >>  typedef itk::SmartPointer<Self>   Pointer;
> >>  typedef itk::SmartPointer<const Self>  ConstPointer;
> >>
> >>  // Method for creation through the object factory.
> >>  itkNewMacro(Self);
> >>
> >>  // Run-time type information (and related methods).
> >>  itkTypeMacro(NonRigidRegistrationMethod, ImageToImageFilter);
> >>
> >>  // ImageDimension enumeration  itkStaticConstMacro(ImageDimension,
> >> unsigned int, TFixedImage::ImageDimension);
> >>
> >>  // Image Types.  typedef          TFixedImage
> >> FixedImageType;
> >>  typedef typename FixedImageType::ConstPointer   FixedImagePointer;
> >>
> >>  typedef          TMovingImage                   MovingImageType;
> >>  typedef typename MovingImageType::ConstPointer  MovingImagePointer;
> >>
> >>  typedef          TOutputImage                   OutputImageType;
> >>  typedef typename OutputImageType::Pointer       OutputImagePointer;
> >>
> >>
> >>  typedef itk::BSplineDeformableTransform
> >>               < double,                 ImageDimension, 3 >
> >> TransformType;
> >>
> >>  typedef typename TransformType::ParametersType    ParametersType;
> >>
> >>  // Initialize the transform with rigid parameters
> >>  void SetRigidTransform( ParametersType );
> >>  //void SetRigidTransform( void * );
> >>
> >>  // Get the final transformation parameters of the registration
> >>  const ParametersType GetFinalTransformParameters( void );
> >>
> >>  // Get the transform
> >>  const TransformType * GetTransform( void );
> >>
> >>  ParametersType                        m_LastTransformParameters;
> >>  ParametersType                        m_RigidTransformParameters;
> >>  typename TransformType::Pointer            m_NonRigidTransform;
> >>
> >> protected:
> >>  NonRigidRegistration();
> >>  virtual ~NonRigidRegistration() {};
> >>  void GenerateData(void );
> >>
> >> private:
> >>
> >>  FixedImagePointer  m_FixedPtr;
> >>  MovingImagePointer m_MovingPtr;
> >>
> >>  void InitializeTransform();
> >> };
> >>
> >>
> >>
> >> #ifndef ITK_MANUAL_INSTANTIATION
> >> #include "NonRigidRegistration.txx"
> >> #endif
> >>
> >> #endif //_NONRIGIDREGISTRATION_H_
> >>
> >>
> >> ------------------------------------------------------------------------
> >>
> >> #include "NonRigidRegistration.h"
> >>
> >> template <typename Type>
> >> inline Type max(Type const& a, Type const& b) { return b < a ? a : b; }
> >>
> >>
> >>
> >> template < typename TFixedImage, typename TMovingImage, typename
> >> TOutputImage >
> >> NonRigidRegistration< TFixedImage, TMovingImage, TOutputImage  >
> >> ::NonRigidRegistration()
> >> {
> >>  this->SetNumberOfRequiredInputs( 2 );
> >>  m_NonRigidTransform      = TransformType::New();
> >>
> >> }
> >>
> >>
> >>
> >> template < typename TFixedImage, typename TMovingImage, typename
> >> TOutputImage >
> >> void
> >> NonRigidRegistration< TFixedImage, TMovingImage, TOutputImage  >
> >> ::SetRigidTransform( ParametersType rigidParameters)
> >> //::SetRigidTransform( void * rigidParameters)
> >> {
> >>  m_RigidTransformParameters = rigidParameters;
> >> //reinterpret_cast<ParametersType *>(rigidParameters);
> >> }
> >>
> >>
> >>
> >> template < typename TFixedImage, typename TMovingImage, typename
> >> TOutputImage >
> >> void
> >> NonRigidRegistration< TFixedImage, TMovingImage, TOutputImage  >
> >> ::InitializeTransform()
> >> {
> >>  typedef typename TransformType::RegionType TransformRegionType;
> >>
> >>  TransformRegionType                             transformGridRegion;
> >>     typename TransformRegionType::SizeType          gridBorderSize;
> >>     typename TransformRegionType::SizeType          totalGridSize;
> >>     typename MovingImageType::RegionType::SizeType  gridSizeOnImage;
> >>
> >>  typename FixedImageType:: SizeType fixedImageSize  = m_FixedPtr->
> >> GetLargestPossibleRegion().GetSize();
> >>  typename MovingImageType::SizeType movingImageSize =
> >> m_MovingPtr->GetLargestPossibleRegion().GetSize();
> >>
> >>  // Set the number of spline nodes.
> >>  // Each spline needs 3 nodes outside the image: 1 on lower and 2 on
> >> the upper border.
> >>  // The number of splines are set in proportion to the image size.
> >>  // At least 2 nodes are needed in each dimension.
> >>  gridBorderSize.Fill(3);  unsigned int numberOfNodesPerDimension = 5;
> >> //Number of nodes in the image
> >>  for (unsigned int ii = 0; ii < ImageDimension; ii++)
> >>  {
> >>    gridSizeOnImage[ii] = max( (int)( numberOfNodesPerDimension *
> >>                                      movingImageSize[ii] /
> >>                                      movingImageSize[0]  ), 2);
> >>  }
> >>
> >>  totalGridSize = gridSizeOnImage + gridBorderSize;
> >>     transformGridRegion.SetSize( totalGridSize );
> >>
> >>     typename TransformType::SpacingType spacing =
> >> m_FixedPtr->GetSpacing();
> >>     typename TransformType::OriginType  origin  =
> >> m_FixedPtr->GetOrigin();
> >>
> >>
> >>     for(unsigned int r=0; r<ImageDimension; r++)  {
> >>         spacing[r] *= floor( static_cast<double>( fixedImageSize[r]
> >> - 1) /                           static_cast<double>(
> >> gridSizeOnImage[r] - 1) );
> >>        origin[r]  -=  spacing[r];  }
> >>
> >>     m_NonRigidTransform->SetGridRegion(  transformGridRegion );
> >>     m_NonRigidTransform->SetGridSpacing( spacing             );
> >>     m_NonRigidTransform->SetGridOrigin(  origin              );
> >>
> >>  typedef typename TransformType::ParametersType TransformParametersType;
> >>  const unsigned int numberOfParameters =
> >> m_NonRigidTransform->GetNumberOfParameters();
> >>  TransformParametersType initialParameters( numberOfParameters );
> >>  initialParameters.fill(0.0);
> >>
> >>  // Parameters are stored in array as x1x2x3x4... y1y2y3y4... z1z2z3z4
> >>  const unsigned int numberOfNodes =
> >> m_NonRigidTransform->GetNumberOfParametersPerDimension();
> >>  for (unsigned int ii=0; ii < numberOfNodes; ii++ )
> >>  {
> >>    for (unsigned int jj=0; jj < ImageDimension; jj++)
> >>    {
> >>      initialParameters[ii+jj*numberOfNodes]   =
> >> m_RigidTransformParameters[jj];
> >>    }
> >>  }
> >>
> >>  m_NonRigidTransform->SetParametersByValue( initialParameters );
> >>  return;
> >> }
> >>
> >>
> >>
> >> template < typename TFixedImage, typename TMovingImage, typename
> >> TOutputImage >
> >> void
> >> NonRigidRegistration< TFixedImage, TMovingImage, TOutputImage  >
> >> ::GenerateData( void ) {
> >>  // Initialize NonRigid Transformation
> >>     this->InitializeTransform();
> >>
> >>     return;
> >> }
> >>
> >>
> >>
> >>
> >> ------------------------------------------------------------------------
> >>
> >> _______________________________________________
> >> Insight-users mailing list
> >> Insight-users at itk.org
> >> http://www.itk.org/mailman/listinfo/insight-users
> >>
> >>
> >
> >
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
> >
>


More information about the Insight-users mailing list