Undefined reference to function error
Sep 11, 2012 at 3:41pm UTC
Hi! When I try to compile this code it gives me this error:
Line: 36, undefined reference to `TextGetcher(std::vector<unsigned char, std::allocator<unsigned char
It's a function that takes a unsigned char vector reference in, when I make it take in same vector in as non reference everything works perfectly.
Heres the code(It's little messy at the moment...):
GameEngine.cpp:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#include "Link.h"
#include <fstream>
#include <io.h>
//******************
//******************
//Engine Functions/classes
//******************
//******************
//getch() input getter function.. mainly used in the menu class...
unsigned char TextGetcher(std::vector <unsigned char > &CharecterInput){ //THE FUNCTION <------------
//variables
bool NonSignifiantInput = true ;
unsigned char InputCharecter;
//function main loop
while (NonSignifiantInput){
InputCharecter = tolower(getch());
for (unsigned short index = 0; index < CharecterInput.size(); ++index){
if (InputCharecter == CharecterInput.at(index)){
NonSignifiantInput = false ;
break ;
}
}
}
//end of the function
return InputCharecter;
}
//********
Functions.cpp 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
#include "Link.h"
#include <fstream>
std::vector <unsigned char > FileReader(unsigned short StartRange, unsigned short EndRange, std::string &FileName);
std::string ReconizeCharecter(unsigned char );
//******************
//******************
//Game Functions/classes
//******************
//******************
//Class that creates menu's!
class Menu{
public :
//Menu Operator
unsigned short MenuOperator(std::vector <std::string> &Options, std::vector <unsigned char > &CharecterInput , unsigned short MenuType, unsigned short CL)
{//MenuType 1 == Vertical , 2 == horizontal
Cursorlocation = CL;
NotEnterPress = true ;
//Menu While Loop
while (NotEnterPress){
//Which type of menu to print
if (MenuType == 1)
PrintVerticalMenu(Options);
else
PrintHorizontalMenu(Options);
//Getting User Input
Input = TextGetcher(CharecterInput); //THIS IS WHERE THE ERROR HAPPENS! <-------------------
//Determining what to do pased on the user Input
if (Input == CharecterInput.at(2)){ // Down
if (Cursorlocation == Options.size() -1 )
Cursorlocation = 0;
else
++Cursorlocation;
}
else if (Input == CharecterInput.at(1)){ //UP
if (Cursorlocation == 0)
Cursorlocation = Options.size() -1 ;
else
--Cursorlocation;
}
else
NotEnterPress = false ;
ClearScreen();
}//End of Menu While Loop
Text.BrightWhiteText();
return Cursorlocation;
}
//********
private :
//Variables
unsigned short Turn;
Color Text;
unsigned char Input;
unsigned short Cursorlocation;
bool NotEnterPress;
};
Link.h: 1 2 3 4 5 6 7 8 9 10 11 12
#ifndef LINK_H_INCLUDED
#define LINK_H_INCLUDED
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <ctype.h>
#include <vector>
unsigned char TextGetcher(std::vector<unsigned char > &CharecterInput);
#endif // LINK_H_INCLUDED
thanks in advance!
Sep 11, 2012 at 4:25pm UTC
Are you linking against the compiled GameEngine.cpp?
Sep 11, 2012 at 5:24pm UTC
thanks Moschops!
I pretty much cleared out my #include chaos and that fixed my problem thanks for your help :)
Topic archived. No new replies allowed.