This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
In function `main':: undefined reference to ...
- From: Graf László <graf dot laszlo at axis dot hu>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 18 Jan 2005 08:32:09 +0100
- Subject: In function `main':: undefined reference to ...
Hi Gurus,
I am Laszlo from Hungary.
Please, take a look at these files:
--- The main file ---------------------------------------------------------------------
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "base.h"
int main(int argc, char* argv[])
{
system("clear");
Base* b = new Base();
printf("\n---------- %s ---------------\n", b->toString());
delete b;
return 0;
}//main
--- The base.h file ---------------------------------------------------------------------
#ifndef __BASE
#define __BASE
class Base{
private:
char* _str;
public:
Base();
Base(Base &);
~Base();
char* toString();
char* toHtml();
};
#endif
--- The base.c file ---------------------------------------------------------------------
#include "base.h"
using namespace std;
Base::Base(Base &s){
}
Base::~Base(){
}
char* Base::toString()
{
char* rv = "this is the toString()";
return rv;
}
char* Base::toHtml()
{
char* rv = "this is the toHtml()";
return rv;
}
--- The Makefile file ---------------------------------------------------------------------
compile :
g++ -c base.c -o base.o
g++ axf.c -o axf.o
clear :
clear
clean :
rm *.o
run :
./axf.o
--------------------------------------------------------------------------------------------
After the command
make clear clean compile run
I got these error messages:
rm *.o
g++ -c base.c -o base.o
g++ axf.c -o axf.o
/tmp/cc2K7HjB.o(.text+0x4a): In function `main':
: undefined reference to `Base::Base[in-charge]()'
/tmp/cc2K7HjB.o(.text+0x88): In function `main':
: undefined reference to `Base::toString()'
/tmp/cc2K7HjB.o(.text+0xaf): In function `main':
: undefined reference to `Base::~Base [in-charge]()'
collect2: ld returned 1 exit status
make: *** [compile] Error 1
Could somebody tell me what is wrong there?
Thank you.
--
László Graf