[Insight-users] Simple (stupid) question re I/O

Bill Lorensen bill.lorensen at gmail.com
Thu Dec 18 13:25:12 EST 2008


Can you post your CMakeLists.txt file?

On Thu, Dec 18, 2008 at 12:58 PM, Neal R. Harvey <harve at lanl.gov> wrote:
> I have recently become interested in ITK as it seems like it can offer a lot
> of what I
> want/need for a whole bunch of projects.
> Anyhoo, I downloaded the code and built it successfully, with no errors or
> problems,
> according to the instructions in the user guide.
> I was all excited, and was working my way through the user guide, trying to
> become
> sufficiently familiar with using the tool kit.
> I thought I would try to read/write a TIFF file (as most of my images are
> TIFF), and produced
> the following (small and simple code), taking baby steps, in which I don't
> even get to the actual
> reading or writing of the TIFF file, based on the
> Examples/IO/ImageReadExportVTK.cxx provided in the ITK code-base:
> (note that if I use the actual ImageReadExportVTK.cxx code provided, I get
> the same errors)
>
> #include "itkImage.h"
> #include <iostream>
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkTIFFImageIO.h"
>
> int main( int argc, char ** argv )
> {
>  if( argc < 3 )
>   {
>     std::cerr << "Usage: " << std::endl;
>     std::cerr << argv[0] << " inputImageFile  outputImageFile " <<
> std::endl;
>     return EXIT_FAILURE;
>   }
>
>  typedef unsigned short      PixelType;
>  const   unsigned int        Dimension = 2;
>  typedef itk::Image< PixelType, Dimension >    ImageType;
>
>  typedef itk::ImageFileReader< ImageType >  ReaderType;
>  typedef itk::ImageFileWriter< ImageType >  WriterType;
>  typedef itk::TIFFImageIO                   ImageIOType;
>
>  ReaderType::Pointer reader = ReaderType::New();
>  WriterType::Pointer writer = WriterType::New();
>  ImageIOType::Pointer tiffIO = ImageIOType::New();
>
>  return EXIT_SUCCESS;
> }
>
> When I compile the code I get the following:
>
> dumbass$ make
> Scanning dependencies of target HelloWorld
> [100%] Building CXX object CMakeFiles/HelloWorld.dir/HelloWorld.o
> Linking CXX executable HelloWorld
> CMakeFiles/HelloWorld.dir/HelloWorld.o: In function
> `itk::ImageIORegion::~ImageIORegion()':
> HelloWorld.cxx:(.text._ZN3itk13ImageIORegionD1Ev[itk::ImageIORegion::~ImageIORegion()]+0x7):
> undefined reference to `vtable for itk::ImageIORegion'
> CMakeFiles/HelloWorld.dir/HelloWorld.o: In function
> `itk::ImageIORegion::ImageIORegion(unsigned int)':
> HelloWorld.cxx:(.text._ZN3itk13ImageIORegionC1Ej[itk::ImageIORegion::ImageIORegion(unsigned
> int)]+0x13): undefined reference to `vtable for itk::ImageIORegion'
> CMakeFiles/HelloWorld.dir/HelloWorld.o: In function
> `itk::ImageIORegion::ImageIORegion(itk::ImageIORegion const&)':
> HelloWorld.cxx:(.text._ZN3itk13ImageIORegionC1ERKS0_[itk::ImageIORegion::ImageIORegion(itk::ImageIORegion
> const&)]+0x13): undefined reference to `vtable for itk::ImageIORegion'
> CMakeFiles/HelloWorld.dir/HelloWorld.o: In function
> `itk::ImageFileReader<itk::Image<unsigned short, 2u>,
> itk::DefaultConvertPixelTraits<unsigned short> >::DoConvertBuffer(void*,
> unsigned long)':
> HelloWorld.cxx:(.text._ZN3itk15ImageFileReaderINS_5ImageItLj2EEENS_25DefaultConvertPixelTraitsItEEE15DoConvertBufferEPvm[itk::ImageFileReader<itk::Image<unsigned
> short, 2u>, itk::DefaultConvertPixelTraits<unsigned short>
>>::DoConvertBuffer(void*, unsigned long)]+0xac6): undefined reference to
> `itk::ImageIOBase::GetComponentTypeAsString(itk::ImageIOBase::IOComponentType)
> const'
> CMakeFiles/HelloWorld.dir/HelloWorld.o: In function
> `itk::ImageFileReader<itk::Image<unsigned short, 2u>,
> itk::DefaultConvertPixelTraits<unsigned short> >::GenerateData()':
> HelloWorld.cxx:(.text._ZN3itk15ImageFileReaderINS_5ImageItLj2EEENS_25DefaultConvertPixelTraitsItEEE12GenerateDataEv[itk::ImageFileReader<itk::Image<unsigned
> short, 2u>, itk::DefaultConvertPixelTraits<unsigned short>
>>::GenerateData()]+0x44b): undefined reference to
> `itk::operator<<(std::basic_ostream<char, std::char_traits<char> >&,
> itk::ImageIORegion const&)'
> HelloWorld.cxx:(.text._ZN3itk15ImageFileReaderINS_5ImageItLj2EEENS_25DefaultConvertPixelTraitsItEEE12GenerateDataEv[itk::ImageFileReader<itk::Image<unsigned
> short, 2u>, itk::DefaultConvertPixelTraits<unsigned short>
>>::GenerateData()]+0x992): undefined reference to
> `itk::ImageIOBase::GetImageSizeInBytes() const'
> CMakeFiles/HelloWorld.dir/HelloWorld.o: In function
> `itk::ImageFileReader<itk::Image<unsigned short, 2u>,
> itk::DefaultConvertPixelTraits<unsigned short>
>>::GenerateOutputInformation()':
> HelloWorld.cxx:(.text._ZN3itk15ImageFileReaderINS_5ImageItLj2EEENS_25DefaultConvertPixelTraitsItEEE25GenerateOutputInformationEv[itk::ImageFileReader<itk::Image<unsigned
> short, 2u>, itk::DefaultConvertPixelTraits<unsigned short>
>>::GenerateOutputInformation()]+0x33b): undefined reference to
> `itk::ImageIOFactory::CreateImageIO(char const*,
> itk::ImageIOFactory::FileModeType)'
> HelloWorld.cxx:(.text._ZN3itk15ImageFileReaderINS_5ImageItLj2EEENS_25DefaultConvertPixelTraitsItEEE25GenerateOutputInformationEv[itk::ImageFileReader<itk::Image<unsigned
> short, 2u>, itk::DefaultConvertPixelTraits<unsigned short>
>>::GenerateOutputInformation()]+0x4d8): undefined reference to `typeinfo for
> itk::ImageIOBase'
> collect2: ld returned 1 exit status
> make[2]: *** [HelloWorld] Error 1
> make[1]: *** [CMakeFiles/HelloWorld.dir/all] Error 2
> make: *** [all] Error 2
>
> It's probably something pretty minor, but it is most frustrating not being
> able to figure out the problem. I have to admit to not being much
> of a C++ programmer, mainly dealing with C.
> Any helpful insights would be very much appreciated.
>
> Cheers
>
> --
> HARVE (Neal R. Harvey)           Email: harve at lanl.gov
> ISR-2                            Phone: 505 667 9077
> Los Alamos National Laboratory   Fax: 505 664 0362
> Los Alamos, NM 87545, USA        Mail Stop: D-436
> The generation of random numbers is too important to be left to chance.
>
> _______________________________________________
> 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