From owner-freebsd-hackers Fri Jan 31 20:43:59 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id UAA03685 for hackers-outgoing; Fri, 31 Jan 1997 20:43:59 -0800 (PST) Received: from gargoyle.bazzle.com (gargoyle.bazzle.com [206.103.246.190]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id UAA03680 for ; Fri, 31 Jan 1997 20:43:52 -0800 (PST) Received: from gargoyle.bazzle.com (net2.bazzle.com [206.103.246.189]) by gargoyle.bazzle.com (8.8.4/8.6.12) with SMTP id XAA16136; Fri, 31 Jan 1997 23:42:36 -0500 (EST) Date: Fri, 31 Jan 1997 23:42:36 -0500 (EST) From: "Eric J. Chet" To: Terry Lambert cc: Bakul Shah , hackers@FreeBSD.ORG Subject: Re: g++, STL and -frepo on FreeBSD-2.2-Beta In-Reply-To: <199702010114.SAA03677@phaeton.artisoft.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Fri, 31 Jan 1997, Terry Lambert wrote: > > cat >x.cc < > #include // include everything for simplicity. > > #include > > #include > > > > int main(int, char*[]) { > > list 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 class and everything should just work. No such luck. I > > get: > > > > x.o: Undefined symbol `list::list(void)' referenced from text segment > ********************* constructor > > x.o: Undefined symbol `list::push_back(int const &)' referenced from text segment > ********************************* type member > > x.o: Undefined symbol `list::~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 list ... { > ... > }; > > is not in scope. The header files you have included are apparently > not sufficient. > > Perhaps you meant "List" instead of "list"??? > Hello The -frepo patches don't work on our version of the g++ and ld. I assume ld is the problem. I haven't had the time to take a look to see what needs to be changed. The -frepo patch from Cygnus when applied, should create a set of *.ii one for each source file complied from g++. The *.ii files specify all templates that need to be instantiated before linking can take place. I believe there is a collect2 module that performs the instantiations task. I do know that if you build g++ with John Polstra's ELF patches and the -frepo patches. Then template repository works as advertised. On the other hand, the only thing you lose by not having the repository with our native compiler is executable size. The compiler will instantiated every template used in a object file and include it in that object file. Meaning, you can have duplicate template instantiations across different object files. Eric J. Chet - ejc@naserver1.cb.lucent.com - ejc@bazzle.com > > Terry Lambert > terry@lambert.org > --- > Any opinions in this posting are my own and not those of my present > or previous employers. >