Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Compiler Error

Reply
Thread Tools

Compiler Error

 
 
fabio
Guest
Posts: n/a
 
      08-28-2003
Gianni Mariani wrote:

> Patrick Coleman wrote:
>> Hi,
>> This may seem to be a basic question, but I keep getting the following
>> error:
>> main.cc:93: undefined reference to
>> `AT_UrlParser::AT_UrlParser[in-charge](char const*,
>> std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
>>
>> line 93:
>> AT_UrlParser qservice(service);
>>
>> I'm including a custom header file that defines AT_UrlParser.
>>
>> What is this error message telling me? It seemed to me that it started
>> happening for no reason at all (that line was compiling fine until I
>> converted some of my char vars to strings and used .c_str() later in the
>> code), but it must have been something I've done.
>>
>> Thanks,
>> Patrick

>
>
> Which version of the compiler are you using ?
>
> It says it is unable to find the constructor defintion.
>
> Are there some more messages ?
>
> Does placing :
>
> AT_UrlParser qservice("http://test.com/test/test.html");
>
> on line 93 change the error ?



I'm just trying to *guess*; it could be a problem of linking. Your function
seems to be declared but not defined anywhere. But it's just a guessing,
try to post your code.

 
Reply With Quote
 
 
 
 
Patrick Coleman
Guest
Posts: n/a
 
      08-28-2003
Hi,
This may seem to be a basic question, but I keep getting the following
error:
main.cc:93: undefined reference to
`AT_UrlParser::AT_UrlParser[in-charge](char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'

line 93:
AT_UrlParser qservice(service);

I'm including a custom header file that defines AT_UrlParser.

What is this error message telling me? It seemed to me that it started
happening for no reason at all (that line was compiling fine until I
converted some of my char vars to strings and used .c_str() later in the
code), but it must have been something I've done.

Thanks,
Patrick
 
Reply With Quote
 
 
 
 
Gianni Mariani
Guest
Posts: n/a
 
      08-28-2003
Patrick Coleman wrote:
> Hi,
> This may seem to be a basic question, but I keep getting the following
> error:
> main.cc:93: undefined reference to
> `AT_UrlParser::AT_UrlParser[in-charge](char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
>
> line 93:
> AT_UrlParser qservice(service);
>
> I'm including a custom header file that defines AT_UrlParser.
>
> What is this error message telling me? It seemed to me that it started
> happening for no reason at all (that line was compiling fine until I
> converted some of my char vars to strings and used .c_str() later in the
> code), but it must have been something I've done.
>
> Thanks,
> Patrick



Which version of the compiler are you using ?

It says it is unable to find the constructor defintion.

Are there some more messages ?

Does placing :

AT_UrlParser qservice("http://test.com/test/test.html");

on line 93 change the error ?

 
Reply With Quote
 
Patrick Coleman
Guest
Posts: n/a
 
      08-28-2003
On Thu, 28 Aug 2003 08:10:47 +0000, Gianni Mariani wrote:

> Patrick Coleman wrote:


<snip>

>
>
> Which version of the compiler are you using ?
>
> It says it is unable to find the constructor defintion.
>
> Are there some more messages ?
>
> Does placing :
>
> AT_UrlParser qservice("http://test.com/test/test.html");
>
> on line 93 change the error ?


Hi,

Here is the relevant code:

---begin---
//Includes
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <errno.h>
#include <at_url_parse.h>

using namespace std;

<snip>

int getnodes (char service[]) //service is a URL
{

<snip>

string host;
string path;

//AT_UrlParser parsedservice(service); //This is my original line
AT_UrlParser qservice("http://test.com/test/test.html"); //This is your suggested line - neither works

host = qservice.m_host;
path = qservice.m_path;

<snip>
}
---end---

The relevant header is 'at_parse_url.h', see thread 'Splitting URLs' in
this group. My compiler messages are below (these are from the
compilation of the code exactly as it is above):

(I am using an IDE (Anjuta) so the compiler messages are not pretty...)

---begin---
<skipping useless make messages>
Making all in src
make[2]: Entering directory `/home/pcoleman/Projects/CECID/src'
if g++ -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/include -Wall -O1 -g -g -O2 -MT cecid-main.o -MD -MP -MF ".deps/cecid-main.Tpo" \
-c -o cecid-main.o `test -f 'main.cc' || echo './'`main.cc; \
then mv ".deps/cecid-main.Tpo" ".deps/cecid-main.Po"; \
else rm -f ".deps/cecid-main.Tpo"; exit 1; \
fi

In file included from main.cc:16:
at_url_parse.h: In constructor `AT_UrlString::AT_UrlString(const std::string&)':
at_url_parse.h:33: warning: base initializer for `std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
at_url_parse.h:33: warning: will be re-ordered to precede member initializations

In file included from main.cc:16:
at_url_parse.h:164:29: warning: no newline at end of file

main.cc: In function `int buildlist()':
main.cc:48: warning: unused variable `int dc'

/bin/sh ../libtool --mode=link g++ -g -O2 -o cecid cecid-main.o
g++ -g -O2 -o cecid cecid-main.o

cecid-main.o(.text+0x403): In function `getnodes(char*)':
/home/pcoleman/Projects/CECID/src/main.cc:94: undefined reference to `AT_UrlParser::AT_UrlParser[in-charge](char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
collect2: ld returned 1 exit status

make[2]: *** [cecid] Error 1
make[2]: Target `all' not remade because of errors.
make[2]: Leaving directory `/home/pcoleman/Projects/CECID/src'
make[2]: Entering directory `/home/pcoleman/Projects/CECID'
make[2]: Leaving directory `/home/pcoleman/Projects/CECID'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/pcoleman/Projects/CECID'
make: *** [all] Error 2

---end---

and heres my output from 'g++ -v'...:

---begin---
Reading specs from /usr/lib/gcc-lib/i386-slackware-linux/3.2.2/specs
Configured with: ../gcc-3.2.2/configure --prefix=/usr --enable-shared --enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld --verbose --target=i386-slackware-linux --host=i386-slackware-linux
Thread model: posix
gcc version 3.2.2
---end---

....so I hope that helps.

Thanks for the assistance,
Patrick

 
Reply With Quote
 
Gianni Mariani
Guest
Posts: n/a
 
      08-28-2003
Rolf Magnus wrote:
> Patrick Coleman wrote:
>
>
>>int getnodes (char service[]) //service is a URL

>
>
> ...
>
>
>>//AT_UrlParser parsedservice(service); //This is my original line
>>AT_UrlParser qservice("http://test.com/test/test.html"); //This is
>>your suggested line - neither works

>
>
>>cecid-main.o(.text+0x403): In function `getnodes(char*)':
>>/home/pcoleman/Projects/CECID/src/main.cc:94: undefined reference to
>>`AT_UrlParser::AT_UrlParser[in-charge](char const*,
>>std::basic_string<char, std::char_traits<char>, std::allocator<char>
>>
>>>*)' collect2: ld returned 1 exit status

>
>
> Seems you declared a constructor for a class named AT_UrlParser that
> thakes a char* and and std::string with at least that std::string as
> default parameter, but you didn't define it, or maybe you forgot to
> link that definition in.


Right.

You need to make sure that at_url_parse.o gets linked in as well.

this line -
>>> g++ -g -O2 -o cecid cecid-main.o


should look like -

g++ -g -O2 -o cecid cecid-main.o at_url_parse.o

It's a simple linker issue.

As for the warnings at_url_parse.h:33, I don't get these on gcc 3.3.1.

I'm no autoconf expert but if you have control of the build tools, look
a MakeXS (shameless plug) on http://freshmeat.net, it would have
automatically done the right thing.


 
Reply With Quote
 
Patrick Coleman
Guest
Posts: n/a
 
      08-29-2003
Hi,
Thanks for all the help. I finally got the problem fixed, and I know a lot
more about including and linking headers now
Thanks,
Patrick
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiler Error Message: The compiler failed with error code -1073741819 Ram ASP .Net 0 09-13-2005 09:52 AM
Why is a JIT compiler faster than a byte-compiler RickMuller Python 4 03-26-2005 04:30 PM
Compiler compiler with C++ as output Andrey Batyuck C++ 3 05-17-2004 08:17 PM
Can we use <compiler> tag to avoid RunTime Compiler error? Jack Wright ASP .Net 5 01-19-2004 04:36 PM
Compiler Error Message: The compiler failed with error code 128. Yan ASP .Net 0 07-21-2003 10:49 PM



Advertisments