LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-07-2004, 02:00 AM   #1
libra610
LQ Newbie
 
Registered: Dec 2004
Posts: 2

Rep: Reputation: 0
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
 
Old 12-07-2004, 02:57 AM   #2
rustynailz
Member
 
Registered: Jun 2004
Distribution: MDK 9.2/10.0, VectorLinux 4.0
Posts: 50

Rep: Reputation: 15
Try g++ instead of gcc.
 
Old 12-07-2004, 03:27 AM   #3
kees-jan
Member
 
Registered: Sep 2004
Distribution: Debian, Ubuntu, BeatrIX, OpenWRT
Posts: 273

Rep: Reputation: 30
Additionally, you should probably also specify the decompress.o file on the command line.

Groetjes,

Kees-Jan
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
link dies intermittently-seemingly at random- between win<->linux not linux<->linux?? takahaya Linux - Networking 10 03-09-2007 10:37 PM
triple boot linux/linux/linux No Windows involved toastermaker Linux - Newbie 12 03-02-2006 10:40 PM
Redhat (rhel v2.1) bootup problem with linux (linux vs linux-up) namgor Linux - Software 2 06-24-2004 02:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration