[Insight-users] link errors, how can I know which .lib should be linked?

=?GB2312?B?wfXQy5VO?= lxssxl at gmail.com
Tue Apr 3 07:25:42 EDT 2007


Dear Luis and all ITK users,

  I tried the example ImageRegionIterator in the
ItkSoftwareGuide-2.4.0(form p738 to p740,and I'll paste the code
below). I typed it according to the
guide. And complied it with VC6. But VC6 reported a lot of warnings
and link errors.

  I didn't konw which lib to add. So I add a lot such as
"ITKBasicFilters ITKCommon ITKIO ITKFltkImageViewer ITKStatistics
ITKNumerics". The warnings
were still there, but the errors were reduced to only one. It read
LINK : fatal error LNK1104: cannot open file '
ITKBasicFilters.obj' ".
  I don't know how to fix the errors and warnings. Can you help me?
And by the way, how can I know which lib is related to my project and
I should
add it to my project?

  Thank you very much in advance!


Regards,
Xing-Sheng Liu

Because the message is too big, I can't paste the warnings and errors
in this mail.
You can see them here: http://docs.google.com/Doc?id=dfgj3tr5_1g4j9q9


the code is here
====================================================================================================================================================



#include "itkImage.h"
#include "itkImageRegionConstIterator.h"
#include "itkImageRegionIterator.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h
"

int main( int argc, char *argv[] )
{
  if ( argc < 7 )
    {
      std::cerr << "Missing parameters. " << std::endl;
      std::cerr << "Usage: " << std::endl;

      std::cerr << argv[0]
                << " inputImageFile outputImageFile startX startY sizeX sizeY"
                << std::endl;
      return -1;
    }


  const unsigned int Dimension = 2;


  typedef unsigned char PixelType;
  typedef itk::Image< PixelType, Dimension >  ImageType;

  typedef itk::ImageRegionConstIterator< ImageType > ConstIteratorType;
  typedef itk::ImageRegionIterator< ImageType>       IteratorType;


  typedef itk::ImageFileReader< ImageType > ReaderType;
  typedef itk::ImageFileWriter< ImageType > WriterType;


  ImageType::RegionType inputRegion;

  ImageType::RegionType::IndexType inputStart;

  ImageType::RegionType::SizeType  size;

  inputStart[0] = ::atoi( argv[3] );
  inputStart[1] = ::atoi( argv[4] );

  size[0]  = ::atoi( argv[5] );
  size[1]  = ::atoi( argv[6] );

  inputRegion.SetSize
( size );
  inputRegion.SetIndex( inputStart );

  ImageType::RegionType outputRegion;

  ImageType::RegionType::IndexType outputStart;

  outputStart[0] = 0;
  outputStart[1] = 0;

  outputRegion.SetSize
( size );
  outputRegion.SetIndex( outputStart );


  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName( argv[1] );
  try
    {
    reader->Update();
    }
  catch ( itk::ExceptionObject &err)

    {
    std::cerr << "ExceptionObject caught !" << std::endl;
    std::cerr << err << std::endl;
    return -1;
    }

  if ( ! reader->GetOutput()->GetRequestedRegion().IsInside( inputRegion ) )

    {
    std::cerr << "Error" << std::endl;
    std::cerr << "The region " << inputRegion << "is not contained
within the input image region "
              << reader->GetOutput()->GetRequestedRegion() << std::endl;

    return -1;
    }


  ImageType::Pointer outputImage = ImageType::New();
  outputImage->SetRegions( outputRegion );
  const ImageType::SpacingType& spacing = reader->GetOutput()->GetSpacing();

  const ImageType::PointType& inputOrigin = reader->GetOutput()->GetOrigin();
  double   outputOrigin[ Dimension ];

  for(unsigned int i=0; i< Dimension; i++)
    {
    outputOrigin[i] = inputOrigin[i] + spacing[i] * inputStart[i];

    }

  outputImage->SetSpacing( spacing );
  outputImage->SetOrigin(  outputOrigin );
  outputImage->Allocate();

  ConstIteratorType inputIt(   reader->GetOutput(), inputRegion  );

  IteratorType      outputIt(  outputImage,         outputRegion );

  for ( inputIt.GoToBegin(), outputIt.GoToBegin(); !inputIt.IsAtEnd();
        ++inputIt, ++outputIt)
    {
    outputIt.Set(  inputIt.Get
()  );
    }


  WriterType::Pointer writer = WriterType::New();
  writer->SetFileName( argv[2] );
  writer->SetInput( outputImage );

  try
    {
    writer->Update();
    }

  catch ( itk::ExceptionObject &err)
    {
    std::cerr << "ExceptionObject caught !" << std::endl;
    std::cerr << err << std::endl;
    return -1;
    }



  return 0;
}
======================================================================================================================================================


<http://docs.google.com/Doc?id=dfgj3tr5_1g4j9q9>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070403/d295fe5f/attachment.html


More information about the Insight-users mailing list