Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Jan 1997 18:14:33 +73700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        bakul@torrentnet.com (Bakul Shah)
Cc:        hackers@freebsd.org
Subject:   Re: g++, STL and -frepo on FreeBSD-2.2-Beta
Message-ID:  <199702010114.SAA03677@phaeton.artisoft.com>
In-Reply-To: <199701311808.NAA14384@chai.plexuscom.com> from "Bakul Shah" at Jan 31, 97 01:08:01 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> cat >x.cc <<EOF
> #include <stl.h>                // include everything for simplicity.
> #include <iostream.h>
> #include <stdlib.h>
> 
> int main(int, char*[]) {
>     list<int> list1;
>     for(int i = 0; i < 10; ++i) {
>         list1.push_back(rand());
>     }
>     return 0;
> }
> EOF
> 
> g++ -frepo -c x.cc
> g++ -o x x.o
> 
> The last step above should call the compiler to instantiate the
> list<int> class and everything should just work.  No such luck.  I
> get:
> 
> x.o: Undefined symbol `list<int>::list(void)' referenced from text segment
                         ********************* constructor
> x.o: Undefined symbol `list<int>::push_back(int const &)' referenced from text segment
                         ********************************* type member
> x.o: Undefined symbol `list<int>::~list(void)' referenced from text segment
                         ********************** destructor

It can't call the constructor, used implicitly in the list1 auto
declarator.  It can't call the destructor, called implicily when the
list1 auto storage goes out of scope of main().  It can't call the
push_back member function, which is explicitly called.


Clearly, the template class definition

	template <class Type>
	class list ... {
		...
	};

is not in scope.  The header files you have included are apparently
not sufficient.

Perhaps you meant "List" instead of "list"???


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702010114.SAA03677>