l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
August 5: Social gathering
Next Installfest:
TBD
Latest News:
Jul. 4: July, August and September: Security, Photography and Programming for Kids
Page last updated:
2006 Feb 02 12:04

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] grokking g++ errors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] grokking g++ errors



Peter Jay Salzman wrote:
I've always had a hard time parsing g++'s verbose error messages. For
example, this code (in ProtoLoan.cc):



// We've been passed a line of a csv file. We'll parse that line and place
// it in a vector so we can populate the protoloan.
//
void ProtoLoan::initialize( const string &str )
{
vector<string> fields;
split( str, back_inserter(fields) );
}


// Takes a string and a container. Splits the string based on comma
// separated fields and places each element into the container. The
// container is defined as a template, so we can use vectors, lists, etc.
//
template <class Out> void split( const string &str, Out os )
{
typedef string::const_iterator iter;

iter i = str.begin();
while ( i != str.end() )
{
i = find_if( i, str.end(), not_comma );

// Find end of next word
iter j = find_if( i, str.end(), is_comma );

// Copy characters in [i, j)
if ( i != str.end() )
*os++ = string(i,j);
i = j;
}
}


Produces this error message:

$ make
g++ -W -Wall -g3 -c -o rmbs.o rmbs.cc
g++ -W -Wall -g3 -c -o protoloan.o protoloan.cc
g++ rmbs.o protoloan.o -o rmbs
protoloan.o: In function `_ZN9ProtoLoan10initializeERKSs':
/cygdrive/c/Documents and Settings/psalzman/home/RMBS/code/C++/protoloan.cc:19:
undefined reference to `void ProtoLoan::split<std::back_insert_iterator<std::vec
tor<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std:
:allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char>

(std::basic_string<char, std::char_traits<char>, std::allocator<char> >
 const&, std::back_insert_iterator<std::vector<std::basic_string<char, std::char
_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, st
d::char_traits<char>, std::allocator<char> > > > >)'
collect2: ld returned 1 exit status
make: *** [rmbs] Error 1



My mind reels trying to parse this.  I understand that split() isn't being
found by the linker, for some reason, but the rest of the message isn't too
helpful.

Is there a way to glean more information from the error message other than
the fact that the function isn't being found?
I usually copy messes like this to an editor and indent them, which returns
some sanity to the picture when you just read off the top couple of levels
of the outline.

"In typemangled function Protoloan::initialize, there was an undefined
reference to a method 'split', templated with a back_insert_iterator,
which accepts two parameters, the first of which is a basic_string and
the second of which is a back_insert_iterator."

It would be nicer if I had a tool to do this visual parsing for me, but
I don't... the source is usually what I concentrate on.

You didn't ask for assistance in actually troubleshooting this problem, but
templates traditionally must be defined before they are instantiated in the
source.  It is possible that newer compilers can handle definition after
instantiation, but I don't know how they do it.

--------
protoloan.o: In function `_ZN9ProtoLoan10initializeERKSs':
/cygdrive/c/Documents and Settings/psalzman/home/RMBS/code/C++/protoloan.cc:19:
undefined reference to
`void ProtoLoan::split<
    std::back_insert_iterator<
        std::vector<
            std::basic_string<
                char
              , std::char_traits<char>
              , std::allocator<char>
            >
          , std::allocator<
                std::basic_string<
                    char
                  , std::char_traits<char>
                  , std::allocator<char>
                >
            >
        >
    >
 > (
    std::basic_string<
        char
      , std::char_traits<char>
      , std::allocator<char>
    > const&
  , std::back_insert_iterator<
        std::vector<
            std::basic_string<
                char
              , std::char_traits<char>
              , std::allocator<char>
            >
          , std::allocator<
                std::basic_string<
                    char
                  , std::char_traits<char>
                  , std::allocator<char>
                >
            >
        >
    >
)



--
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil@dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
O'Reilly and Associates
For numerous book donations.