Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
Piece.o(.text+0xd): In function `Piece::Piece[not-in-charge]()': * : undefined reference to `Matrix<int>::Matrix[in-charge]()' * Piece.o(.text+0x23): In function `Piece::Piece[in-charge]()': * : undefined reference to `Matrix<int>::Matrix[in-charge]()' What does this mean. I have Matrix linked in ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User
    Join Date
    Apr 2003
    Location
    TEXAS
    Posts
    314

    Undefined Reference


    Piece.o(.text+0xd): In function `Piece::Piece[not-in-charge]()':
    * : undefined reference to `Matrix<int>::Matrix[in-charge]()'
    * Piece.o(.text+0x23): In function `Piece::Piece[in-charge]()':
    * : undefined reference to `Matrix<int>::Matrix[in-charge]()'


    What does this mean.

    I have Matrix linked in the g++ command.

    Any suggestions
    The computer made me do it!! Slackware and SUSE too Gig\'em WHOOOOP!!
    \"God put me on this earth to accomplish a certain amount of tasks, At the rate I\'m going I will never die.\" (I don\'t know)

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    What is this? What is Matrix? What does your exact g++ command look like?

  3. #3
    Linux User
    Join Date
    Apr 2003
    Location
    TEXAS
    Posts
    314
    OK well matrix is a template class of a vector of vectors.

    Im using KDevelop

    Code:
    /bin/sh ../libtool --mode=link g++ -lSDL -o tetris tetris.o Grafix.o Color.o Piece.o Board.o Matrix.o  
    * g++ -o tetris tetris.o Grafix.o Color.o Piece.o Board.o Matrix.o /usr/lib/libSDL.so -lm -L/opt/kde/lib -ldl -lartsc -lpthread -L/usr/lib /usr/lib/libesd.so /usr/lib/libaudiofile.so -lm -L/usr/X11R6/lib -lX11 -lXext -ldl
    Im using kdeveloper iWhat does undefined reference meen. Is it a linker error or what
    The computer made me do it!! Slackware and SUSE too Gig\'em WHOOOOP!!
    \"God put me on this earth to accomplish a certain amount of tasks, At the rate I\'m going I will never die.\" (I don\'t know)

  4. #4
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Can you post the class definition of Matrix?

  5. #5
    Linux User
    Join Date
    Apr 2003
    Location
    TEXAS
    Posts
    314
    Code:
    #ifndef _MATRIX_H_
    #define _MATRIX_H_
    #include <vector>
    #include <iostream>
    
    using namespace std;
    
    template <class T>
    class Matrix
    &#123;
     public&#58;
       Matrix&#40;&#41;;
       Matrix&#40;Matrix <T> &&#41;;
       Matrix&#40;int,int&#41;;
       Matrix&#40;vector <vector<T> > &&#41;;
       Matrix&#40;T **,int,int&#41;;
       ~Matrix&#40;&#41;;
       
       void Set_Rows&#40;int&#41;;  //adds rows onto the end
       void Set_Cols&#40;int&#41;;  //adds cols onto the end
       void Set&#40;T,int,int&#41;;
       
       T& Get&#40;int,int&#41; const;
       int Get_R_Size&#40;&#41;;
       int Get_C_Size&#40;&#41;;
       
       void Clear&#40;&#41;;
     private&#58;
       vector < vector<T> > mat;
       int expand;
    &#125;;
    
    #endif
    The computer made me do it!! Slackware and SUSE too Gig\'em WHOOOOP!!
    \"God put me on this earth to accomplish a certain amount of tasks, At the rate I\'m going I will never die.\" (I don\'t know)

  6. #6
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    What does it look like where Piece allocates a Matrix?

  7. #7
    Linux User
    Join Date
    Apr 2003
    Location
    TEXAS
    Posts
    314
    Code:
    Piece&#58;&#58;Piece&#40;int **mat,int s,int X,int Y&#41; &#123;
      matrix = new Matrix<int>&#40;mat,s,s&#41;;
      size=s;
      x=X;
      y=Y;
    &#125;
    The computer made me do it!! Slackware and SUSE too Gig\'em WHOOOOP!!
    \"God put me on this earth to accomplish a certain amount of tasks, At the rate I\'m going I will never die.\" (I don\'t know)

  8. #8
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Aren't there more? It seems the error comes from Piece::Piece(). Do you have such a constructor for Piece?

  9. #9
    Linux User
    Join Date
    Apr 2003
    Location
    TEXAS
    Posts
    314
    Code:
    #include "Piece.h"
    #include <iostream>
    #include "Matrix.h"
    
    using namespace std;
    
    Piece&#58;&#58;Piece&#40;&#41;
    &#123;
    &#125;
    
    Piece&#58;&#58;Piece&#40;int **mat,int s,int X,int Y&#41; &#123;
      matrix = new Matrix<int>&#40;mat,s,s&#41;;
      size=s;
      x=X;
      y=Y;
    &#125;
    
    Piece&#58;&#58;~Piece&#40;&#41;
    &#123;
    &#125;
    
    void Piece&#58;&#58;Rotate&#40;&#41;
    &#123;
      int s=size;
      int temp&#91;s&#93;&#91;s&#93;;
      
      for&#40;int i=0;i<s;i++&#41; &#123;
        for&#40;int j=0, l=&#40;s-1&#41;;j<s;j++,l--&#41; &#123;
          temp&#91;l&#93;&#91;i&#93;=matrix->Get&#40;i,j&#41;;
          //temp&#91;l&#93;&#91;i&#93;=matrix&#91;i&#93;&#91;j&#93;;
        &#125;
      &#125;
      
      for&#40;int i=0;i<s;i++&#41; &#123;
        for&#40;int j=0;j<s;j++&#41; &#123;
          matrix->Set&#40;temp&#91;i&#93;&#91;j&#93;,i,j&#41;;
          //matrix&#91;i&#93;&#91;j&#93;=temp&#91;i&#93;&#91;j&#93;;
        &#125;
      &#125;
    &#125;
    
    int **Piece&#58;&#58;Get_Piece&#40;&#41;
    &#123;
      int r = matrix->Get_R_Size&#40;&#41;;
      int c = matrix->Get_C_Size&#40;&#41;;
      int **temp;
      
      temp = new int*&#91;r&#93;;
      for&#40;int i=0;i<r;i++&#41; &#123;
        temp&#91;i&#93; = new int&#91;c&#93;;
      &#125;
      
      for&#40;int i=0;i<r;i++&#41; &#123;
        for&#40;int j=0;j<c;j++&#41; &#123;
          temp&#91;i&#93;&#91;j&#93;=matrix->Get&#40;i,j&#41;;
        &#125;
      &#125;
      
      return temp;
    &#125;
    
    int Piece&#58;&#58;Get_Size&#40;&#41;
    &#123;
      return size;
    &#125;
    The computer made me do it!! Slackware and SUSE too Gig\'em WHOOOOP!!
    \"God put me on this earth to accomplish a certain amount of tasks, At the rate I\'m going I will never die.\" (I don\'t know)

  10. #10
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Undefined reference means that the linker can't find the actual function that Piece.o is referring to. I find it strange; it's almost as if you hadn't implemented Matrix::Matrix(T **, int, int) in Matrix.c.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •