home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!sun-barr!sh.wide!fgw!fdm!flab!zodiac!zodiac!vander
- From: vander@flab.fujitsu.co.jp (Mike van der Velden)
- Newsgroups: comp.lang.c++
- Subject: undefined symbol... sometimes
- Message-ID: <VANDER.92Nov6145301@vancouver.stars.flab.Fujitsu.co.jp>
- Date: 6 Nov 92 05:53:01 GMT
- Sender: news@zodiac.hi.flab.fujitsu.co.jp
- Organization: Fujitsu Laboratories Ltd., Kawasaki, Japan
- Lines: 56
- Nntp-Posting-Host: vancouver.hi.flab.fujitsu.co.jp
-
- I have a curious problem. If I have the following three files:
-
- base.h:
- ------
- template <class T>
- class Base {
- public:
- void func ();
- //...
- };
-
-
- base.cc:
- -------
- #include "base.h"
-
- template<class T> void Base<T>::func ( )
- {
- //...
- }
-
-
- main.cc:
- -------
- #include "base.h"
-
- main ()
- {
- class Derived : public Base<Derived> {
- //...
- };
-
- Derived test;
- test.func ();
- }
-
-
- And compile with the command "g++ base.cc main.cc" I get the
- following linker error:
-
- ld: Undefined symbol
- _func__t4Base1ZQ24main7Derived
- collect: /usr/bin/ld returned 2 exit status
-
-
- On the other hand, if I put everything in one file, everything
- compiles fine. I gather that the compiler is mangling the function
- name in one file differently than it does in other files. Have I
- missed something? Is this really correct behavior? Is there a
- work-around?
-
- --
- Mike van der Velden
- s-mail: Distributed Systems Laboratory, Fujitsu Laboratories Ltd.
- 1015, Kamikodanaka Nakahara-ku, Kawasaki 211, Japan
- e-mail: vander@flab.fujitsu.co.jp
-