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

Pieter Vos pieterv@radiology.azn.nl
Tue, 19 Mar 2002 17:02:06 +0100 (CET)


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;
}
-- 
Pieter Vos
Doddendaal 190 Nijmegen
Tel.: 06-18876433
mailto:pieterv@radiology.azn.nl