home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / gnu / g / help / 1203 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.4 KB  |  69 lines

  1. Xref: sparky gnu.g++.help:1203 comp.lang.c++:13398
  2. Newsgroups: gnu.g++.help,comp.lang.c++
  3. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!picasso.informatik.rwth-aachen.de!thoennis
  4. From: thoennis@picasso.informatik.rwth-aachen.de (Hans Juergen Thoennissen)
  5. Subject: linking template classes
  6. Message-ID: <1992Sep8.115747.137@Urmel.Informatik.RWTH-Aachen.DE>
  7. Sender: gnulists@ai.mit.edu
  8. Organization: University of Aachen, W-Germany
  9. Date: Tue, 8 Sep 1992 11:57:47 GMT
  10. Lines: 57
  11.  
  12. Hello,
  13.  
  14. this is my first posting in the usenet so please sorry for choosing the wrong groups ..... but I need help !!!
  15.  
  16. I have a problem with the GNU C++ V2.1 Compiler on my SPARCstation SLC, using  sunos4.1.1 !!!
  17.  
  18. The problem is the following:
  19.  
  20. FILE1:         foo_test.cc
  21.  
  22. #include "foo.h"
  23.  
  24. main() {
  25.     Array<int> ALF;
  26. }
  27.  
  28. FILE2:       foo.h
  29.  
  30. template <class Typ>
  31. class Array {
  32. public:   Array() {Init();}
  33. private: void Init();
  34. };
  35.  
  36. FILE3:     foo.cc
  37.  
  38. #include "foo.h"
  39. template <class Typ> void
  40. Array<Typ>::Init() {
  41. }
  42.  
  43.  
  44. COMMANDS:
  45.  
  46. g++ -c  foo.cc
  47. g++ foo_test.cc foo.o
  48.  
  49. This results in the following linker error:
  50.  
  51. ld: Undifined symbol
  52.       _Init__t5Array1Zi
  53. collect:   /usr/bin/ld returned 2 exit status
  54.  
  55.  
  56. But if I put all 3 files in one, it works. 
  57.  
  58. It seems, that the linker has a problem with the template class. 
  59. Can anybody explain what I am doing wrong or if something is not
  60. installed correctly.
  61.  
  62. Thanks in advance
  63.  
  64. Hans-Juergen
  65.  
  66.  
  67.  
  68.  
  69.