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

Pieter Vos pieterv@radiology.azn.nl
Wed, 20 Mar 2002 09:49:43 +0100 (CET)


Hi,

I have installed ITK on a Linux systems and indeed I mend the line
>   ImageType::Pointer myImage = ImageType::New();
So the problem should be a linking problem. Maybe it's because of an
addition I did in CMakeCache.txt:

//Use the system's version of the standard C++ library (STL and
// streams). If 'OFF', ITK will build against a supplied version
// of the standard library from SGI. On SGI systems, this should
// be set to 'OFF'.
ITK_USE_SYSTEM_STDLIB:BOOL=ON

But when I remove the line I get a lot of errors which begins with:

In file included from /usr/include/g++-3/iostream.h:31,
error, error etc.

So iostream.h is not found???
Can I see that in some cache file, which ITKCommon is used?
I included this time the compile messages, maybe does that help?

Many thanks for the time being used,

Pieter Vos
-----------------------------------------
c++ -g -O2 -ftemplate-depth-50 
-I/data/cemri/TestITK/DM/imageReader 
-I/data/cemri/Insight 
-I/data/cemri/Insight/Code/Numerics 
-I/data/cemri/Insight/Code/Common 
-I/data/cemri/Insight/Code/Numerics/vxl 
-I/data/cemri/Insight/Code/Numerics/vxl 
-I/data/cemri/Insight/Code/Numerics/vxl/vcl 
-I/data/cemri/Insight/Code/Numerics/vxl/vcl 
-I/data/cemri/Insight/Utilities/png 
-I/data/cemri/Insight/Utilities/zlib 
-I/data/cemri/Insight/Code/IO 
-I/data/cemri/Insight/Code/BasicFilters 
-I/data/cemri/Insight/Code/Algorithms   
-D_PTHREADS -c /data/cemri/TestITK/DM/imageReader/test.cxx -o test.o

c++ -rdynamic -g -O2 -ftemplate-depth-50 test.o  
-L/data/cemri/Insight/Code/Common 
-L/data/cemri/Insight/Code/Numerics/vxl 
-L/data/cemri/Insight/Code/IO 
-L/data/cemri/Insight/Code/Numerics 
-lpthread -ldl -lVXLNumerics -lITKIO -lITKCommon -lm 
-lpthread -ldl -lVXLNumerics -lITKIO -lITKCommon -lm
-Wl,-rpath,/data/cemri/Insight/Code/Common:/data/cemri/Insight/Code/Numerics/vxl:/data/cemri/Insight/Code/IO:/data/cemri/Insight/Code/Numerics
-o VTKImage


------------------------------------------





On Tue, 19 Mar 2002, Luis Ibanez wrote:

> 
> 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;
> >}
> >
> 
> 
> 
> 
> 

-- 
Pieter Vos
Doddendaal 190 Nijmegen
Tel.: 06-18876433
mailto:pieterv@radiology.azn.nl