0

From what I've googled, it seems like symbol reference errors are linking errors.. If I am wrong, please let me know.

I'm trying to make a very simple program(DataReader.cpp) that takes inputs from a text file and saves them in a form specified in Data.cpp/Data.h. But I keep getting symbol reference errors

g++ -Wall DataReader.o Data.o -o DataReader
Undefined                       first referenced
 symbol                             in file
Data::Data(char, char, char, char, char, char, char, char, char, bool)DataReader.o
ld: fatal: Symbol referencing errors. No output written to DataReader

What can I do to resolve this issue? I've been working at it for a while now but I have not a single clue. Again, it's a real simple program that includes vector, iostream and fstream. So I presume that there's no need for me to link libraries or anything, do I? I've used those before and didn't have to link it explicitly.

Thank you!!

edit:
this is my makefile..

all: DataReader

DataReader.o: DataReader.cpp
	g++ -Wall -c DataReader.cpp -o DataReader.o
	
Data.o: Data.cpp
	g++ -Wall -c Data.cpp -o Data.o

DataReader: DataReader.o Data.o
	g++ -Wall DataReader.o Data.o -o DataReader
class Data
{

private:
	
	char UL;					// Upper Left Corner of the board
	char UM;					// Upper Middle
	char UR;					// Upper Right
	char ML;					// Middle Left
	char MM;					// Middle Middle
	char MR;					// Middle Right
	char BL;					// Bottom Left
	char BM;					// Bottom Middle
	char BR;					// Bottom Right
	bool result;				// Classification Result
	
	
public:

	Data();			// default constructor
	Data(	char _UL, char _UM, char _UR,
			char _ML, char _MM, char _MR,
			char _BL, char _BM, char _BR, bool _result );

	void setData(char _UL, char _UM, char _UR,
				char _ML, char _MM, char _MR,
				char _BL, char _BM, char _BR, bool _result );
	
	char getUL();
	char getUM();
	char getUR();
	char getML();
	char getMM();
	char getMR();
	char getBL();
	char getBM();
	char getBR();
	bool getResult();
	
};
#include "Data.h"

void Data::setData(char _UL, char _UM, char _UR,
					char _ML, char _MM, char _MR,
					char _BL, char _BM, char _BR, bool _result)
{
	UL = _UL;
	UM = _UM,
	UR = _UR;
	ML = _ML;
	MM = _MM;
	MR = _MR;
	BL = _BL;
	BM = _BM;
	BR = _BR;
	result = _result;
};


char Data::getUL()	{	return UL;	}
char Data::getUM()	{	return UM;	}
char Data::getUR()	{	return UR;	}
char Data::getML()	{	return ML;	}
char Data::getMM()	{	return MM;	}
char Data::getMR()	{	return MR;	}
char Data::getBL()	{	return BL;	}
char Data::getBM()	{	return BM;	}
char Data::getBR()	{	return BR;	}
bool Data::getResult() {	return result;	}
#include <fstream>
#include <iostream>
#include <vector>
#include "Data.h"

using namespace std;

int main()
{
	ifstream boardComboText;
	char att;
	char buffer[28];
	Data * something = new Data('x','x','x','x','x','x','x','x','x',1);
	att = (*something).getML();
	cout << "something " << att;
	vector<Data> database;
	
	boardComboText.open("tic-tac-toe-training.txt");
	if(!boardComboText)
	{
		cerr << "file can't be opened";
		exit(1);
	}
/*
	while(! boardComboText.eof())
	{
		boardComboText.getline(buffer,27);
		bool result;
		if(buffer[18] == 'p')
			result = 1;
		else
			result = 0;
		Data temp = new Data(buffer[0], buffer[2], buffer[4],
								buffer[6], buffer[8], buffer[10],
								buffer[12], bufffer[14], buffer[16], result);
								
		database.insert(temp);
	}
*/
	boardComboText.close();
	
	return 0;
}

Much thanks to anyone who read this mess of a code...

Edited by Aild: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Aild
Featured Replies
1

Course)
No body of Data constructor, only the declaration.

Comments
Thank you very much!!!
0

Course)
No body of Data constructor, only the declaration.

...

wow.. that did fix the problem alright. THANK YOU VERY MUCH!!!!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.