[Insight-users] Creating an 3D image fails with an exeptional error

Luis Ibanez luis.ibanez@kitware.com
Tue, 19 Mar 2002 11:22:39 -0500


Hi Pieter,

Your C++ code looks fine and the CMakeList.txt seems to be Ok too.

The problem could be originated by a mix of old and new versions of the
libraries at link time...

Are you running on Windows or Unix  ?

Please correct me if I'm wrong:
When you said that the problem lies near the declaration of the image
with it's pointer, you mean the line:

  ImageType::Pointer myImage = ImageType::New();

Is that right ?

At this level the only library involved is ITKCommon.lib which manages
the Factories for creation of new objects through the New() operator.
I would suspect that for some reason your program is being linked with
an old version of the ITKCommon.lib library.  Are you creating dll's for
ITK libraries ?  

Do you have by any chance, both an ITKCommon.dll and
ITKCommon.lib in the same ITK binary directory ?



  Thanks

     Luis

===========================================


Pieter Vos wrote:

>As one can see in the example below, I'm trying to create a 3D image.
>It is a short version of the example itkImageLinearIteratorTest.cxx
>Compiling goes well, but when I execute the program I get the following
>error:
>"error while loading shared libraries: unexpected reloc type 0x84"
>sometimes other hexa-numbers or after some changes in the code:
>"segmentation fault"
>An error what seems to occur more when one surfs on the internet.
>The strange part is when I compile and run itkImageLinearIteratorTest.cxx
>no errors occur. 
>While stripping the code the problem lies near the declaration of the
>image with it's pointer.
>So maybe something is wrong in the CMakeList.txt or Cache, but I
>can't find what. I included the .txt file as well.
>
>Many thanks in advance!
>
>Pieter Vos
>
>-------------------------------------------------------
>
># Deformable model test program
>PROJECT(ITK_TEST)
>
>SET(ITK_SOURCE_DIR /data/cemri/Insight)
>SET(ITK_BINARY_DIR /data/cemri/Insight)
>
># Include the ITK include and link libraries
>INCLUDE (${ITK_SOURCE_DIR}/itkCMakeOptions.cmake)
>
>
>LINK_LIBRARIES (
>VXLNumerics
>ITKIO
>ITKCommon
>-lm
>)
>
>
>LINK_DIRECTORIES(
>${ITK_BINARY_DIR}/Code/IO
>${ITK_BINARY_DIR}/Code/Numerics
>${ITK_BINARY_DIR}/Code/Common
>)
>
>
>
>INCLUDE_DIRECTORIES(
>${ITK_SOURCE_DIR}/Code/IO
>${ITK_SOURCE_DIR}/Code/BasicFilters
>${ITK_SOURCE_DIR}/Code/Algorithms
>)
>
>#grouping files
>SOURCE_FILES( ITK_SRCS test)
>
>ADD_EXECUTABLE(VTKImage ITK_SRCS)
>
>
>
>
>-----------------------------example----------------
>#include <iostream>
>
>#include "itkImage.h"
>#include "itkImageLinearIteratorWithIndex.h"
>
>
>int main()
>{
>  std::cout << "Creating an image of indices" << std::endl;
>  const unsigned int ImageDimension = 3;
>  typedef itk::Index< ImageDimension >             PixelType;
>  typedef itk::Image< PixelType, ImageDimension >  ImageType;
>  ImageType::Pointer myImage = ImageType::New();
>  ImageType::SizeType size;
>
>  size[0] = 100;
>  size[1] = 100;
>  size[2] = 100;
>
>  ImageType::IndexType start;
>  start = ImageType::IndexType::ZeroIndex;
>
>  ImageType::RegionType region;
>  region.SetIndex( start );
>  region.SetSize( size );
>
>  myImage->SetLargestPossibleRegion( region );
>  myImage->SetBufferedRegion( region );
>  myImage->SetRequestedRegion( region );
>  myImage->Allocate();
>
>  return 1;
>}
>