Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!sdd.hp.com!mips!sgi!shinobu!odin!sgihub!zola!twilight!dragon!xanadu.wpd.sgi.com!pal From: pal@xanadu.wpd.sgi.com (Anil Pal) Newsgroups: comp.lang.c++ Subject: Re: Need help, missing virtual tables, Sun C++ 2.0 Keywords: Sun Message-ID: <1991May9.173442.5946@dragon.wpd.sgi.com> Date: 9 May 91 17:34:42 GMT References: <1991May8.224321.12580@cs.utk.edu> Sender: news@dragon.wpd.sgi.com (CNews Account) Reply-To: pal@wpd.sgi.com Organization: Silicon Graphics, Inc. Lines: 35 In article <1991May8.224321.12580@cs.utk.edu>, mullens@jamsun.ic.ornl.gov (James A. Mullens) writes: |> First, would anyone posting an answer also point me to a "frequently asked |> questions" list and a Sun C++ 2.0 compiler bug list? Sorry, I don't know where to find such a beast. However, I will post an answer regardless :-) |> The problem is that the loader complains of undefined symbols such as |> ___vtbl__23SGob__BaseGob__ViewMngr__7WinMngr, meaning (I think) the virtual |> function table for class WinMngr (a class derived from ViewMngr, BaseGob, and |> SGob). The trick here is understanding where the translator puts the virtual function table. In order to reduce the number of copies of the virtual function table, cfront-based translators (I believe Sun C++ 2.0 is one) use the following strategy: The virtual function table for a class is output in a compilation stream if the compilation stream contains the *definition* for the first non-inline virtual function *declared* in that class. Simple :-) So, how do you use this information? Well, look at the class in question (and its base classes) and determine which is the first non-inline virtual function declared (perhaps one of your base classes has a virtual destructor?). Then check to see that you have included in your link the appropriate definition for that function in your class. In my experience, this is the most common cause of undefined vtables at link time. Note that if a pure virtual function is declared in a derived class, it will not generate any warnings. You may still have forgotten to provide an implementation for a declared function, and if no-one calls it, you will not be told that it is undefined. -- Anil A. Pal, Silicon Graphics, Inc. pal@wpd.sgi.com (415)-335-7279