Thread: Unresolved Externals!

  1. #1
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802

    Unresolved Externals!

    This is more of a continuation of a previous problem, but the other post was filled with unrelated stuffs.

    I have a class, CMatrix which has a few accessor methods (GetMatrix(), GetSingle(), GetRows(), GetColumns(), GetDimensions())

    I've declared these const, as they don't change anything within the class.. but now that they're const I get unresolved external errors when I call them. Everything is fine until I try to call these functions, If I don't call them.. I can compile fine.

    These are the errors I get:

    Matrix.obj : error LNK2001: unresolved external symbol "public: double __thiscall CMatrix::GetSingle(unsigned short,unsigned short)" (?GetSingle@CMatrix@@QAENGG@Z)
    Matrix.obj : error LNK2001: unresolved external symbol "public: short __thiscall CMatrix::GetColumns(void)" (?GetColumns@CMatrix@@QAEFXZ)
    Matrix.obj : error LNK2001: unresolved external symbol "public: short __thiscall CMatrix::GetRows(void)" (?GetRows@CMatrix@@QAEFXZ)
    Here's my main cpp file which tests some of the classes methods.

    Code:
    main.cpp
    #include "stdafx.h"
    #include "CMatrix.h"
    #include <iostream>
    
    int main(int argc, char* argv[])
    {
    	// Testing...
    	using std::endl;
    	CMatrix Matrix(5, 5);
    
    	Matrix.SetSingle(3, 4, 4.302);
    	Matrix.Redimension(6, 6);
    
    	CMatrix CopyMatrix(6, 6);
    	CopyMatrix.SetSingle(3, 4, 4.232);
    
    	Matrix.Copy(CopyMatrix);
    
    	Matrix.Clear();
    	Matrix.Redimension(6, 6);
    
    	Matrix.SetRow(1, 3.32, 4.32, 5.13, 6.75, 7.87, 6.55);
    
    	for (int i = 0; i < Matrix.GetRows(); i++)
    	{
    		for (int ii = 0; ii < Matrix.GetColumns(); ii++)
    		{
    			std::cout << Matrix.GetSingle(i, ii) << endl;
    		}
    	}
    
    			
    	return 0;
    }
    The declarations of these methods in CMatrix.h
    Code:
    CMatrix.h
    	double **GetMatrix() const;
    	// Returns a pointer to an array of doubles, representing a matrix;
    
    	double GetSingle(unsigned short int iRowNum, unsigned short int iColumnNum) const;
    	// Retrives a single element from the matrix;
    
    
    	void GetDimensions(short int &iRow, short int &iColumn) const;
    	// Fills dColumn and dRow with dimension values;
    
    	short GetColumns() const;
    	// Returns the number of columns;
    
    	short GetRows() const;
    And the definitions of these methods in CMatrix.cpp

    Code:
    CMatrix.cpp
    double CMatrix::GetSingle(unsigned short int iRowNum, unsigned short int iColumnNum) const
    {
    	if (m_pdMatrixData == NULL) return NULL;
    	if (iRowNum > m_iDimension[0] || iRowNum < 1) return NULL;
    	if (iRowNum > m_iDimension[1] || iRowNum < 1) return NULL;
    	// Error Checking;
    
    	return m_pdMatrixData[iRowNum][iColumnNum];
    }
    
    
    short CMatrix::GetRows() const
    {
    	if (m_pdMatrixData == NULL) return 0;
    
    	return m_iDimension[0];
    }
    
    short CMatrix::GetColumns() const
    {
    	if (m_pdMatrixData == NULL) return 0;
    
    	return m_iDimension[1];
    }
    
    void CMatrix::GetDimensions(short int &iRow, short int &iColumn) const
    {
    	if (m_pdMatrixData == NULL)
    	{
    		iRow = 0;
    		iColumn = 0;
    		return;
    	}
    	iRow = m_iDimension[0];
    	iColumn = m_iDimension[1];
    }
    
    double **CMatrix::GetMatrix() const
    {
    	if (m_pdMatrixData == NULL) return NULL;
    	return m_pdMatrixData;
    }
    These errors have been holding me back for almost a week, someone please help!
    Last edited by Dual-Catfish; 06-20-2002 at 02:28 PM.

  2. #2
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469
    Didn't read your code but unresolved externals usually means that you don't have a need library included

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Could you post the rest of CMatrix.cpp so the code can at least be compiled?

  4. #4
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Sure. I'll upload my zipped project here.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. Unresolved Externals
    By nickname_changed in forum C++ Programming
    Replies: 10
    Last Post: 08-31-2003, 06:13 PM
  5. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 03:01 PM