[Insight-users] link errors, how can I know which .lib should
be linked?
Luis Ibanez
luis.ibanez at kitware.com
Tue Apr 3 08:16:48 EDT 2007
Hi 刘兴昇
It seems that you are not using
CMake for configuring your project.
Please read the Tutorials:
http://www.itk.org/HTML/Tutorials.htm
In particular:
http://www.itk.org/CourseWare/Training/GettingStartedI-WebPage/index.htm
This tutorial guide you step by step on how to configure
and build ITK, and how to use it from your projects.
You should also read the first three Chapters of
the ITK Software Guide.
http://www.itk.org/ItkSoftwareGuide.pdf
That describe how to configure a project.
Please take the time of reading the documentation,
it will save you a lot of time down the line.
Regards,
Luis
------------------
刘兴昇 wrote:
> 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>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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