[Insight-users] Compiling ITK program under Linux

Martin SEISER m.seiser at 2die4.com
Wed Sep 14 06:17:15 EDT 2005


Hi Luis and hi to all others,

at the moment I am trying to port my Windows ITK application to my LINUX system:

SUSE LINUX 9.3 professional
gcc version 3.3.5 20050117
KDevelop 3.2

I am using the ITK CVS Version and built it by using CMake 2.0.6

Have used one single class that looks like this:

ibiaImageBase.h:

#ifndef ibiaImageBase_h
#define ibiaImageBase_h

#include <itkImage.h>
#include <itkImageFileReader.h>
#include <itkCastImageFilter.h>

namespace ibia {
	template <class PixelTypeT, unsigned int DimensionsT>
		/**
		* Class ImageBase. Defines the base class for all pixel based images.
		*/
    class ImageBase : public itk::Image<PixelTypeT, DimensionsT>  {
      public:
				struct ImageBaseSelf {
					typedef ibia::ImageBase<PixelTypeT, DimensionsT> Self;
				};

				struct ImageBaseSuperclass {
					typedef itk::Image<PixelTypeT, DimensionsT> Superclass;
				};

				struct ImageBasePointer {
					typedef itk::SmartPointer<ImageBaseSelf::Self> Pointer;
				};
				
				struct ImageBaseConstPointer {
					typedef itk::SmartPointer<const ImageBaseSelf::Self> ConstPointer;
				};

				struct ImageBaseConstWeakPointer {
					typedef itk::WeakPointer<const ImageBaseSelf::Self>  ConstWeakPointer;
				};

				itkTypeMacro(ImageBaseSelf::Self, ImageBaseSuperclass::Superclass);
        unsigned int GetDimensions();
        void Copy(ImageBaseSelf::Self* in);

			protected:
        ImageBase();
        virtual ~ImageBase();
				static ImageBasePointer::Pointer LoadInternal(const std::string& fileName);
			private:
				ImageBase(const ImageBaseSelf::Self& in); 
        void operator=(const ImageBaseSelf::Self& in);
   };
}

#endif

ibiaImageBase.cpp:

#include "ibiaImageBase.h"

using namespace ibia;

template <class PixelTypeT, unsigned int DimensionsT>
/**
* Getter.
* Gets value of member component 'DimensionsT'.
* @return unsigned int number of dimensions.
*/
unsigned int ImageBase<PixelTypeT, DimensionsT>::GetDimensions() {
	return DimensionsT;
}

template <class PixelTypeT, unsigned int DimensionsT>
/**
* Copy the image of 'in' into 'this'.
* Takes the pixel data of input and stores data within 'this' image.
* @param in Pointer to an ImageBase class of the same pixel type and the same dimensions.
*/
void ImageBase<PixelTypeT, DimensionsT>::Copy(ImageBase<PixelTypeT, DimensionsT>::ImageBaseSelf::Self* in) {
	if (0 != in) {
		in->Update();
		SetRegions(in->GetLargestPossibleRegion());
		CopyInformation(in);
		Allocate();

		const unsigned long numberOfPixels = this->GetBufferedRegion().GetNumberOfPixels();
		PixelTypeT* buffer = GetBufferPointer();
		PixelTypeT* inBuffer = in->GetBufferPointer();

		memcpy(buffer, inBuffer, numberOfPixels * sizeof(PixelTypeT));
	}
}

template <class PixelTypeT, unsigned int DimensionsT>
/**
* Default constructor.
* Resets all member components.
*/
ImageBase<PixelTypeT, DimensionsT>::ImageBase() : ImageBase<PixelTypeT, DimensionsT>::ImageBaseSuperclass::Superclass() {
}

template <class PixelTypeT, unsigned int DimensionsT>
/**
* De-constructor.
*/
ImageBase<PixelTypeT, DimensionsT>::~ImageBase() {
}

template <class PixelTypeT, unsigned int DimensionsT>
/**
* Load an image with the given file name.
* @param fileName name of the image file to load. The type is determined by the file name's extension.
* @return itk::SmartPointer to the loaded image. NULL if loading fails.
*/
ImageBase<PixelTypeT, DimensionsT>::ImageBasePointer::Pointer ImageBase<PixelTypeT, DimensionsT>::LoadInternal(const std::string& fileName) {
	typedef itk::ImageFileReader< Superclass > ReaderType;
	ReaderType::Pointer reader = ReaderType::New();

	reader->SetFileName(fileName.c_str());

	try {
		// actually read the file
		reader->Update();
	}
	catch (itk::ExceptionObject & err) { 
		std::cout << "Error loading file " << fileName << std::endl;
		std::cout << err << std::endl; 
		return 0;
	} 
	catch (...) {
		std::cout << "Error loading file " << fileName << std::endl;
		return 0;
	}

	reader->UpdateLargestPossibleRegion();

	// cast image from itk::Image to ibia::ImageBase
	typedef itk::CastImageFilter< Superclass , Self> CastType;
	CastType::Pointer caster = CastType::New();

	caster->SetInput(reader->GetOutput());
	caster->UpdateLargestPossibleRegion();
	Pointer img = caster->GetOutput();

	return img;
}

template <class PixelTypeT, unsigned int DimensionsT>
/**
* Copy-Constructor.
* Not implemented in this version.
* @param in object the contains data to be copied.
*/
ImageBase<PixelTypeT, DimensionsT>::ImageBase(const ImageBase<PixelTypeT, DimensionsT>::ImageBaseSelf::Self& in) {
}

template <class PixelTypeT, unsigned int DimensionsT>
/**
* operator=.
* Not implemented in this version.
* @param in object the contains data to be assigned.
*/
void ImageBase<PixelTypeT, DimensionsT>::operator=(const ImageBase<PixelTypeT, DimensionsT>::ImageBaseSelf::Self& in) {
}

I am using Automake and get the following errors:

cd '/ibia/programming/projects/c++/ibiaimagelibrary/debug' && WANT_AUTOCONF_2_5="1" WANT_AUTOMAKE_1_6="1" gmake -k 
cd . && /bin/sh ./config.status Makefile 
config.status: creating Makefile
gmake all-recursive
Making all in src
cd .. && /bin/sh ./config.status src/Makefile depfiles
config.status: creating src/Makefile
config.status: executing depfiles commands
compiling ibiaImageBase.cpp (g++)
In file included from /usr/include/c++/3.3.5/bits/fpos.h:44,
from /usr/include/c++/3.3.5/iosfwd:49,
from /usr/include/c++/3.3.5/ios:44,
from /usr/include/c++/3.3.5/ostream:45,
from /usr/include/c++/3.3.5/iostream:45,
from /ibia/programming/extlibraries/Insight/Code/Common/itkLightObject.h:24,
from /ibia/programming/extlibraries/Insight/Code/Common/itkObject.h:23,
from /ibia/programming/extlibraries/Insight/Code/Common/itkDataObject.h:23,
from /ibia/programming/extlibraries/Insight/Code/Common/itkImageBase.h:23,
from /ibia/programming/extlibraries/Insight/Code/Common/itkImage.h:20,
from /ibia/programming/projects/c++/ibiaimagelibrary/src/ibiaImageBase.h:24,
from /ibia/programming/projects/c++/ibiaimagelibrary/src/ibiaImageBase.cpp:21:
/usr/include/c++/3.3.5/i586-suse-linux/bits/c++io.h:43: error: syntax error before `;' token
/usr/include/c++/3.3.5/i586-suse-linux/bits/c++io.h:45: error: syntax error before `;' token
In file included from /usr/include/c++/3.3.5/bits/stl_algobase.h:69,
from /usr/include/c++/3.3.5/memory:54,
from /usr/include/c++/3.3.5/string:48,
from /usr/include/c++/3.3.5/bits/locale_classes.h:47,
from /usr/include/c++/3.3.5/bits/ios_base.h:47,
from /usr/include/c++/3.3.5/ios:49,
from /usr/include/c++/3.3.5/ostream:45,
from /usr/include/c++/3.3.5/iostream:45,
from /ibia/programming/extlibraries/Insight/Code/Common/itkLightObject.h:24,
from /ibia/programming/extlibraries/Insight/Code/Common/itkObject.h:23,
from /ibia/programming/extlibraries/Insight/Code/Common/itkDataObject.h:23,
from /ibia/programming/extlibraries/Insight/Code/Common/itkImageBase.h:23,
from /ibia/programming/extlibraries/Insight/Code/Comm
on/itkImage.h:20,
from /ibia/programming/projects/c++/ibiaimagelibrary/src/ibiaImageBase.h:24,
from /ibia/programming/projects/c++/ibiaimagelibrary/src/ibiaImageBase.cpp:21:
/usr/include/c++/3.3.5/new:82: error: `size_t' undeclared in namespace `std'
/usr/include/c++/3.3.5/new:82: error: declaration of `operator new' as non-function
/usr/include/c++/3.3.5/new:82: error: invalid declarator
/usr/include/c++/3.3.5/new:83: error: `size_t' undeclared in namespace `std'
/usr/include/c++/3.3.5/new:83: error: declaration of `operator new []' as non-function
/usr/include/c++/3.3.5/new:83: error: invalid declarator
/usr/include/c++/3.3.5/new:86: error: `size_t' undeclared in namespace `std'
/usr/include/c++/3.3.5/new:86: error: syntax error before `::' token
/usr/include/c++/3.3.5/new:86: error: `operator new' takes type `size_t' (` unsigned int') as first parameter
/usr/include/c++/3.3.5/new:87: error: `size_t' undeclared in namespace `std'
/usr/include/c++/3.3.5/new:87: er
ror: syntax error before `::' token
/usr/include/c++/3.3.5/new:87: error: `operator new' takes type `size_t' (` unsigned int') as first parameter
/usr/include/c++/3.3.5/new:92: error: `size_t' undeclared in namespace `std'
/usr/include/c++/3.3.5/new:92: error: syntax error before `*' token
/usr/include/c++/3.3.5/new:92: error: `operator new' takes type `size_t' (` unsigned int') as first parameter
/usr/include/c++/3.3.5/new: In function `void* operator new(unsigned int, ...)
':
/usr/include/c++/3.3.5/new:92: error: `__p' undeclared (first use this function)
/usr/include/c++/3.3.5/new:92: error: (Each undeclared identifier is reported only once for each function it appears in.)
/usr/include/c++/3.3.5/new: At global scope:
/usr/include/c++/3.3.5/new:93: error: `size_t' undeclared in namespace `std'
/usr/include/c++/3.3.5/new:93: error: syntax error before `*' token
/usr/include/c++/3.3.5/new:93: error: `operator new' takes type `size_t' (` unsigned int') as first parameter
In file included from /usr/include/c++/3.3.5/bits/stl_algobase.h:73,
from /usr/include/c++/3.3.5/memory:54,
from /usr/include/c++/3.3.5/string:48,
from /usr/include/c++/3.3.5/bits/locale_classes.h:47,
from /usr/include/c++/3.3.5/bits/ios_base.h:47,
from /usr/include/c++/3.3.5/ios:49,
from /usr/include/c++/3.3.5/ostream:45,
from /usr/include/c++/3.3.5/iostream:45,
from /ibia/programming/extlibraries/Insight/Code/Common/itkLightObject.h:24,
from /ibia/programming/extlibraries/Insight/Code/Common/itkObject.h:23,
from /ibia/programming/extlibraries/Insight/Code/Common/itkDataObject.h:23,
from /ibia/programming/extlibraries/Insight/Code/Common/itkImageBase.h:23,
from /ibia/programming/extlibraries/Insight/Code/Common/itkImage.h:20,
from /ibia/programming/projects/c++/ibiaimagelibrary/src/ibiaImageBase.h:24,
from /ibia/programming/projects/c++/ibiaimagelibrary/src/ibiaImageBase.cpp:21:
/usr/include/c++/3.3.5/bits/stl_iterator_base_types.h:102: error: syntax error before `,' token
/usr/include/c++/3.3.5/bits/stl_iterator_base_types.h:109: error: template declaration of `typedef _Tp std::value_type'
/usr/include/c++/3.3.5/bits/stl_iterator_base_types.h:109: confused by earlier errors, bailing out
gmake[2]: *** [ibiaImageBase.o] Fehler 1
gmake[2]: Das Target &#187;all&#171; wurde wegen Fehlern nicht aktualisiert.
gmake[1]: *** [all-recursive] Fehler 1
gmake: *** [all] Fehler 2
*** Exited with status: 2 ***

Can you or anyone help me here please???

thx a lot

Martin

-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm



More information about the Insight-users mailing list