C++ on Linux
Hi All!
I have a problem in using C++ on Linux
I have a class name decompress, it is declared in decompress.h and decompress.cpp file like this:
////////////////////////////////
decompress.h file
class decompress
{
public:
char* a;
void setinfo(char* b);
decompress();
~decompress();
};
///////////////////////////////
decompress.cpp file
#include "decompress.h"
/////////////////////////////////////////////////////////////////
decompress::decompress()
{
}
decompress::~decompress()
{
}
void decompress::setinfo(char* b)
{
this->a = b;
}
/////////////////////////////////////////////
In test1.cpp file, I use this class like this:
#include "decompress.h"
int main(int argc, char* argv[])
{
printf("Hello World!\n");
decompress* de;
de = new decompress();
de->setinfo("hoang dung");
printf("%s ",de->a);
return 0;
}
When I run the command line
gcc -g -o test1 test1.o -L.
I have errors like this:
test1.o(.text+0x35): In function `main':
/home/MelissaDataProjects/ELOTRelease/test1/test1.cpp:8: undefined reference to
`operator new(unsigned)'
test1.o(.text+0x4a):/home/MelissaDataProjects/ELOTRelease/test1/test1.cpp:8: undefined reference to `decompress::decompress[in-charge]()'
test1.o(.text+0x73):/home/MelissaDataProjects/ELOTRelease/test1/test1.cpp:8: undefined reference to `operator delete(void*)'
test1.o(.text+0x98):/home/MelissaDataProjects/ELOTRelease/test1/test1.cpp:8: undefined reference to `operator delete(void*)'
test1.o(.text+0xad):/home/MelissaDataProjects/ELOTRelease/test1/test1.cpp:9: undefined reference to `decompress::setinfo(char*)'
test1.o(.gnu.linkonce.d.DW.ref.__gxx_personality_v0+0x0):/home/MelissaDataProjects/ELOTRelease/test1/test1.cpp:6: undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
I don't know the reason why. Is there anyone can help me?
Thanks a lot.
libra
|