[Insight-users] Problems with itkMatrix and vnl_matrix_fixed

Luke Bloy luke.bloy at gmail.com
Mon Dec 22 10:05:00 EST 2008


Hi all,

I'm having a strange problem with itkMatrix and vnl_matrix_fixed. For 
some reason it seems that itkMatrix can't be templated with a dimensions 
more then 6? the problem is the it can't link to vnl_matrix_fixed with 
that size. Here is code the will replicate the problem.

#include "itkMatrix.h"

int main( int argc, char * argv[])
{
  typedef itk::Matrix < double, 6u, 6u >      mat6Type;
  typedef itk::Matrix < double, 7u, 7u >      mat7Type;
 
  mat6Type mat6;
  mat6.SetIdentity();

  mat7Type mat7;
  mat7.SetIdentity();
 
  std::cerr << "mat6  : " << std::endl << mat6  << std::endl;
  std::cerr << "mat7  : " << std::endl << mat7 << std::endl;
  return EXIT_SUCCESS;  
}

##In CMakeFiles.txt
ADD_EXECUTABLE(MatrixTest MatrixTest.cxx)
TARGET_LINK_LIBRARIES(MatrixTest ITKNumerics ITKCommon)


So this code will not link.

CMakeFiles/MatrixTest.dir/MatrixTest.o: In function `itk::Matrix<double, 7u, 7u>::SetIdentity()':

MatrixTest.cxx:(.text._ZN3itk6MatrixIdLj7ELj7EE11SetIdentityEv[itk::Matrix<double, 7u, 7u>::SetIdentity()]+0xd): undefined reference to `vnl_matrix_fixed<double, 7u, 7u>::set_identity()'

CMakeFiles/MatrixTest.dir/MatrixTest.o: In function `std::basic_ostream<char, std::char_traits<char> >& operator<< <double, 7u, 7u>(std::basic_ostream<char, std::char_traits<char> >&, vnl_matrix_fixed<double, 7u, 7u> const&)':

MatrixTest.cxx:(.text._ZlsIdLj7ELj7EERSoS0_RK16vnl_matrix_fixedIT_XT0_EXT1_EE[std::basic_ostream<char, std::char_traits<char> >& operator<< <double, 7u, 7u>(std::basic_ostream<char, std::char_traits<char> >&, vnl_matrix_fixed<double, 7u, 7u> const&)]+0x14): undefined reference to `vnl_matrix_fixed<double, 7u, 7u>::print(std::basic_ostream<char, std::char_traits<char> >&) const'

collect2: ld returned 1 exit status

make[2]: *** [bin/MatrixTest] Error 1

make[1]: *** [Testing/CMakeFiles/MatrixTest.dir/all] Error 2



If I comment out the mat7 lines it will compile and run...
mat6  :
1 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1


Any Ideas?

Thanks,
Luke


More information about the Insight-users mailing list