[Insight-users] Help with "Undefined references during linking"

Luis Ibanez luis.ibanez at kitware.com
Tue Apr 4 09:14:45 EDT 2006


Hi Martin,

Please post the *exact* error messages that you get.

Are you compiling this on Linux ? or Windows ?


   Please let us know,


      Thanks


         Luis



---------------------
Martin Kavec wrote:
> Hi,
> 
> I am writing a piece of IO code to read a FSL affine transform file. The 
> transform is (always) stored in an ASCII file as a 4x4 matrix, so it is 
> should not be a "rocket science" to read it.
> 
> My code is based on Code/IO/itkTransformFileREader.cxx, except that 
> the ::Update() method will be different. I attached the header, 
> implementation, CMakeList.txt and small test code to make it easier to 
> compile.
> 
> The code compiles fine, but the linker complains about missing references 
> to ::Update(), ::New() and ::Create() methods.
> 
> I tried to figure out what's wrong, but no luck, so I would appreciate a help. 
> Thanks.
> 
> Martin
> 
> 
> ------------------------------------------------------------------------
> 
> PROJECT( itkFSLAffineTransformFileReader )
> 
> FIND_PACKAGE(ITK)
> IF(ITK_FOUND)
>   INCLUDE(${ITK_USE_FILE})
> ELSE(ITK_FOUND)
>   MESSAGE(FATAL_ERROR
>             "Cannot build InsightApplications without ITK.  Please set ITK_DIR.")
> ENDIF(ITK_FOUND)
> 
> SET(CMAKE_VERBOSE_MAKEFILE ON)
> ADD_DEFINITIONS(-Wall)
> 
> INCLUDE_REGULAR_EXPRESSION(".*")
> 
> ADD_EXECUTABLE(itkFSLAffineTransformFileReaderTest itkFSLAffineTransformFileReaderTest.cxx )
> TARGET_LINK_LIBRARIES(itkFSLAffineTransformFileReaderTest ITKStatistics ITKCommon ITKNumerics ITKMetaIO ITKIO)
> 
> 
> ------------------------------------------------------------------------
> 
> /*=========================================================================
> 
>   Program:   Insight Segmentation & Registration Toolkit
>   Module:    $RCSfile: itkFSLAffineTransformFileReader.cxx,v $
>   Language:  C++
>   Date:      $Date: 2006/04/02 12:00:00 $
>   Version:   $Revision: 1.0 $
> 
>      This software is distributed WITHOUT ANY WARRANTY; without even 
>      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
>      PURPOSE.  See the above copyright notices for more information.
> 
> =========================================================================*/
> #ifndef __itkFSLAffineTransformFileReader_cxx
> #define __itkFSLAffineTransformFileReader_cxx
> 
> #include "itkFSLAffineTransformFileReader.h"
> 
> #include <itksys/ios/sstream>
> 
> namespace itk
> {
> 
> /** Constructor */
> FSLAffineTransformFileReader::FSLAffineTransformFileReader()
> {
>   m_FileName = "";
> 
>   TransformPointer m_Transform = TransformType::New();
>   m_Transform->SetIdentity();
> }
> 
> /** Destructor */
> FSLAffineTransformFileReader::~FSLAffineTransformFileReader()
> {
> }
> 
> /** Update the Reader */
> void FSLAffineTransformFileReader::Update()
> {
> }
> 
> 
> } // namespace itk
> 
> #endif
> 
> 
> ------------------------------------------------------------------------
> 
> #if defined(_MSC_VER)
> #pragma warning ( disable : 4786 )
> #endif
> 
> #ifdef __BORLANDC__
> #define ITK_LEAN_AND_MEAN
> #endif
> 
> #include "itkFSLAffineTransformFileReader.h"
> 
> #include "itkAffineTransform.h"
> 
> int main(int argc, char* argv[])
> {
> 
>   if( argc < 1 )
>   {
>      std::cerr << "Usage: " << std::endl;
>      std::cerr << argv[0] << " fsl.mat"
>                << std::endl;
>     return EXIT_FAILURE;
> 
>   }
> 
>   typedef itk::FSLAffineTransformFileReader TransformReaderType;
>   TransformReaderType::Pointer transformReader = TransformReaderType::New();
> 
>   transformReader->SetFileName( argv[1] );
> 
>   try{
>      transformReader->Update();
>   }
>   catch(itk::ExceptionObject & excp ) {
>      std::cerr << "Error while reading the transform from file: " << argv[1] << std::endl;
>      std::cerr << excp << std::endl;
>      return EXIT_FAILURE;
>   }
> 
>   typedef itk::AffineTransform< double, 3 > AffineTransformType;
>   AffineTransformType::Pointer fslTransform = transformReader->GetTransform();
> 
>   fslTransform->Print( std::cout );
> 
>   return EXIT_SUCCESS;
> }
> 
> 
> ------------------------------------------------------------------------
> 
> /*=========================================================================
> 
>   Program:   Insight Segmentation & Registration Toolkit
>   Module:    $RCSfile: itkFSLAffineTransformFileReader.h,v $
>   Language:  C++
>   Date:      $Date: 2006/04/02 12:00:00 $
>   Version:   $Revision: 1.0 $
> 
>      This software is distributed WITHOUT ANY WARRANTY; without even 
>      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
>      PURPOSE.  See the above copyright notices for more information.
> 
> =========================================================================*/
> #ifndef __itkFSLAffineTransformFileReader_h
> #define __itkFSLAffineTransformFileReader_h
> 
> #include "itkLightProcessObject.h"
> #include "metaTransform.h"
> #include "itkAffineTransform.h"
> 
> namespace itk
> {
> 
> class FSLAffineTransformFileReader : public LightProcessObject
> {
> public:
> 
>   /** SmartPointer typedef support */
>   typedef FSLAffineTransformFileReader Self;
>   typedef SmartPointer< Self > Pointer;
>   typedef AffineTransform< double, 3u > TransformType;
>   typedef TransformType::ParametersType ParametersType;
>   typedef TransformType::Pointer TransformPointer;
> 
>   /** Method for creation through the object factory */
>   itkNewMacro( Self );
> 
>   /** Run-time type information (and related methods). */
>   typedef Object Superclass;
>   itkTypeMacro( FSLAffineTransformFileReader, LightProcessObject );
> 
>   /** Set the filename  */
>   itkSetStringMacro( FileName );
> 
>   /** Get the filename */
>   itkGetStringMacro( FileName );
> 
>   /** Get transform macro */
>   TransformPointer GetTransform( ) const {
>      return m_Transform;
>   }
> 
>   /** Write out the transform */
>   void Update();
> 
> protected:
> 
>   std::string m_FileName;
> 
>   FSLAffineTransformFileReader();
>   virtual ~FSLAffineTransformFileReader();
> 
> private:
> 
>   TransformPointer m_Transform;
> 
> };
> 
> } // namespace itk
> 
> 
> #endif // __itkFSLAffineTransformFileReader_h
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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