home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / gcc / help / 3004 < prev    next >
Encoding:
Text File  |  1993-01-23  |  1.3 KB  |  53 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!teeny.redbrick.com!johnson
  2. From: johnson@teeny.redbrick.com (Galt Johnson)
  3. Newsgroups: gnu.gcc.help
  4. Subject: Undefined symbol from g++ during load
  5. Date: 22 Jan 1993 19:31:38 -0500
  6. Organization: GNUs Not Usenet
  7. Lines: 41
  8. Sender: daemon@cis.ohio-state.edu
  9. Distribution: gnu
  10. Message-ID: <9301230030.AA25728@teeny.redbrick.com>
  11.  
  12. The gnu c++ compiler version 2.3.3 doesn't seem to be emitting code for the template
  13. operator<< routine.  When I issue the command:
  14.     g++ test.cc
  15. I get the following complaint from the loader:
  16.     ld: Undefined symbol 
  17.        ___ls__FR7ostreamRt4Test1Zi 
  18.     collect: /usr/bin/ld returned 2 exit status
  19.  
  20. Is there a compiler switch I'm missing?
  21.  
  22. I'm using gcc-2.3.3 on a SPARCstation(SunOS 4.1).
  23.  
  24. Galt Johnson
  25. johnson@redbrick.com
  26.  
  27. ----------------------------------------------------------------------
  28. #include <iostream.h>
  29.  
  30. template <class T> class Test{
  31. public:
  32.     Test(T i) : val(i) {}
  33.  
  34.     friend ostream& operator<<(ostream &s, Test<T>& t);
  35. private:
  36.     T val;
  37. };
  38.  
  39. template <class T>
  40. ostream& operator<<(ostream& s, Test<T> &h)
  41. {
  42.     s << h.val;
  43.     return s;
  44. };
  45.  
  46. main()
  47. {
  48.     Test<int> i(3);
  49.  
  50.     cout << "This is a test :" << i << endl;
  51. }
  52. ----------------------------------------------------------------------
  53.