LinuxQuestions.org
Visit Jeremy's Blog.
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 05-04-2006, 11:12 AM   #1
an-arhos
LQ Newbie
 
Registered: May 2006
Posts: 4

Rep: Reputation: 0
g++ linking trouble ?


Hi,
I'm trying to compile some simple c++ program, but I can't.

I am using this command

g++ -o parser-example srcsrc/parser-example.cpp

and I get this output:

Quote:
/root/tmp/ccZhkMoC.o(.text+0x1c): In function `main':
: undefined reference to `CgiParser::CgiParser[in-charge]()'
/root/tmp/ccZhkMoC.o(.text+0x56): In function `main':
: undefined reference to `CgiParser:perator<<(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/root/tmp/ccZhkMoC.o(.text+0xd0): In function `main':
: undefined reference to `CgiParser::is_empty()'
/root/tmp/ccZhkMoC.o(.text+0x126): In function `main':
: undefined reference to `CgiParser::get_value(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/root/tmp/ccZhkMoC.o(.text+0x292): In function `main':
: undefined reference to `CgiParser:perator<<(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/root/tmp/ccZhkMoC.o(.text+0x29b): In function `main':
: undefined reference to `CgiParser:perator<<(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/root/tmp/ccZhkMoC.o(.text+0x2a4): In function `main':
: undefined reference to `CgiParser:perator<<(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/root/tmp/ccZhkMoC.o(.text+0x448): In function `main':
: undefined reference to `CgiParser::get_value(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/root/tmp/ccZhkMoC.o(.text+0x5b7): In function `main':
: undefined reference to `CgiParser:perator<<(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/root/tmp/ccZhkMoC.o(.text+0x5c0): In function `main':
: undefined reference to `CgiParser:perator<<(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/root/tmp/ccZhkMoC.o(.text+0x5c9): In function `main':
: undefined reference to `CgiParser:perator<<(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/root/tmp/ccZhkMoC.o(.text+0x753): In function `main':
: undefined reference to `CgiParser:perator<<(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/root/tmp/ccZhkMoC.o(.text+0x7d6): In function `main':
: undefined reference to `CgiParser:perator<<(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: ld returned 1 exit status
I've tried to compile some more complicated files and I couldn't do it so I mean't that I didn't link librarys well, but this is so simple example wich uses none library and I do not understand what is the problem.

Can anybody help please ?
 
Old 05-04-2006, 12:01 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
There looks to be a class called CgiParser, which the linker can't find. Is this in another file to parser-example.cpp?
 
Old 05-04-2006, 12:30 PM   #3
an-arhos
LQ Newbie
 
Registered: May 2006
Posts: 4

Original Poster
Rep: Reputation: 0
This class is decalred in file parser.h.
That file is the only one included in parser-example.cpp.
 
Old 05-04-2006, 12:38 PM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Where are the CgiParser functions defined, parser.cpp maybe? If so that file will also need to be compiled and linked.
 
Old 05-04-2006, 12:45 PM   #5
an-arhos
LQ Newbie
 
Registered: May 2006
Posts: 4

Original Poster
Rep: Reputation: 0
Off course You are right.
When I included parser.cpp in compiling process it worked.
Thnx
 
Old 05-04-2006, 01:05 PM   #6
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
No worries
 
  


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
Trouble: mounting, linking, permissions. crackery Linux - Newbie 2 01-28-2005 09:03 PM
g++ trouble linking against archive exitsfunnel Programming 3 01-05-2005 09:16 AM
Trouble linking with libmqueue on Linux 2.6.5 -mm illuminatedwax Programming 0 04-14-2004 07:55 AM
trouble linking with g++ WanglessOlasov Programming 5 12-28-2003 12:25 PM
trouble ahead, trouble behind....trouble with mplayer Goonie Linux - Software 3 07-02-2003 02:29 AM

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

All times are GMT -5. The time now is 11:49 AM.

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