[Insight-users] an LNK2001 ERROR

Luis Ibanez luis.ibanez at kitware.com
Fri Apr 25 11:20:30 EDT 2008


Hi Zhang,

You are missing to link with the ITKNumerics library.

Please replace the line

    TARGET_LINK_LIBRARIES(HelloWorld ITKCommon ITKIO)

with the line

    TARGET_LINK_LIBRARIES(HelloWorld ITKNumerics ITKIO ITKCommon)



Regards,


     Luis


--------------------
zhang xiaohui wrote:
> 
> Hi Luis,
> 
> I read about your lectures about registration and want to plot the 
> metric. There is an error  :(  What's wrong?
> 
> error LNK2001: Nichtaufgeloestes externes Symbol "protected: virtual 
> void __thiscall itk::CostFunction::PrintSelf(class 
> std::basic_ostream<char,struct std::char_traits<char> > &,class 
> itk::Indent)const " 
> (?PrintSelf at CostFunction@itk@@MBEXAAV?$basic_ostream at DU?$char_traits at D@std@@@std@@VIndent at 2@@Z)
> 
> 
> I add ITKCommon and ITKIO in the library
> TARGET_LINK_LIBRARIES(HelloWorld ITKCommon ITKIO)
> 
> --program--
> 
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkMeanSquaresImageToImageMetric.h"
> #include "itkMattesMutualInformationImageToImageMetric.h"
> #include "itkLinearInterpolateImageFunction.h"
> #include "itkTranslationTransform.h"
> #include <iostream>
> 
> int main()
> {
>     const    unsigned int    ImageDimension = 2;
>     typedef  unsigned char   PixelType;
>     typedef itk::Image< PixelType, ImageDimension >   ImageType;
>     typedef itk::ImageFileReader< ImageType >  ReaderType;
> 
>     ReaderType::Pointer ImageReader = ReaderType::New();
>     ImageReader->SetFileName( "leber1.TIF");
>     ImageReader->Update();
>     ImageType::Pointer input = ImageReader->GetOutput();
> 
>     typedef itk::LinearInterpolateImageFunction< ImageType, double > 
> InterpolatorType;
>     InterpolatorType::Pointer interpolator = InterpolatorType::New();
> 
> 
>     typedef itk::TranslationTransform< double, ImageDimension >  
> TransformType;
>     TransformType::Pointer transform = TransformType::New();
> 
>     typedef itk::MeanSquaresImageToImageMetric< ImageType, ImageType >  
> MetricType;
>     MetricType::Pointer metric = MetricType::New();
> 
>     metric->SetInterpolator( interpolator );
>     metric->SetTransform( transform );
> 
>     metric->SetFixedImage(  input  );
>     metric->SetMovingImage( input );
> 
>     MetricType::TransformParametersType translation( ImageDimension );
> 
>     double value[21][21];
> 
>     for( int dx = 0; dx <= 20; dx++)
>     {
>         for( int dy = 0; dy <= 20; dy++)
>         {
>             translation[0] = dx;
>             translation[1] = dy;
> 
>             value[dx][dy] = metric->GetValue( translation );
>         }
>     }
> 
> }
> 
> 
> Thanks and have nice weekend!
> 
> Sophie


More information about the Insight-users mailing list