[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::c_plus_plus

Title:C++
Notice:Read 1.* and use keywords (e.g. SHOW KEY/FULL KIT_CXX_VAX_VMS)
Moderator:DECCXX::AMARTIN
Created:Fri Nov 06 1987
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3604
Total number of notes:18242

3503.0. "undefined symbol using template" by MUNICH::WWERNER (When in doubt, do as the INTs do) Wed Mar 19 1997 05:45

What is CXXL$LSXN7OSTRAMNK10SMNP109JBEU ? The question arises because of
the following program. (Open VMS Alpha 6.2, DEC C++ V5.5-017)

Wolfgang

$ CXX EXA05_MAIN
$ CXXLINK EXA05_MAIN
%LINK-W-NUDFSYMS, 1 undefined symbol:
%LINK-I-UDFSYM,         CXXL$LSXN7OSTRAMNK10SMNP109JBEU
%LINK-W-USEUNDEF, undefined symbol CXXL$LSXN7OSTRAMNK10SMNP109JBEU referenced
in psect $LINK$ offset %X00000060
in module EXA05___C file SYS$USER:[WERNER.TMP.CXX_REPOSITORY]EXA05___C.OBJ;1


$ TYPE EXA05_MAIN.CXX
#include <iostream.h>
#include <iomanip.h>

#include "exa05.h"

int main() {

  exa05<char>   ec('a');
  ec.ToStream(cout);
  return 0;
}

$ TYPE EXA05.H
template <class T>
class exa05<T> {
  private:
    T         m_value;
  public:
              exa05<T>(T value);
    void      ToStream(ostream& os) const;
};

$ TYPE EXA05.CXX
template <class T>
exa05<T>::exa05(T value) {
  m_value = value;
}

template <class T>
void exa05<T>::ToStream(ostream& os) const {
  os << setw(6);  // no linker warning error if replaced with 'os.width(6);' 
  os << m_value;
}

T.RTitleUserPersonal
Name
DateLines
3503.1DECC::FOLTANWed Mar 19 1997 09:4718
Yes, I am able to reproduce your problem.

$ cxx/version exa05_main.cxx
DEC C++ V5.5-017 on OpenVMS Alpha V6.2-1H3
$ cxx exa05_main.cxx
$ cxxlink exa05_main.obj
%LINK-W-NUDFSYMS, 1 undefined symbol:
%LINK-I-UDFSYM,         CXXL$LSXN7OSTRAMNK10SMNP109JBEU
%LINK-W-USEUNDEF, undefined symbol CXXL$LSXN7OSTRAMNK10SMNP109JBEU referenced
        in psect $LINK$ offset %X00000060
        in module EXA05___C file GEM_C$:[FOLTAN.WORK.CXX_REPOSITORY]EXA05___C.OB
J;1

I suspect the sybol is coming from the class library.
I will have someone take a look.

Lois
3503.2shows bug in automatic instantiation, will be fixed in next release of compiler (V5.6)DECC::J_WARDWed Mar 19 1997 10:0323
This is the unresolved symbol:

Unresolved:
operator <<(ostream&, const smanip_int&)

The problem you have linking is due to a bug in
the automatic instantiation mechanism that will be fixed
in V5.6 of the compiler (it corresponds to our internal
bug database number CXXC_BUGS 3926). It happens because
this operator is declared as a friend function in
the iomanip header. 

For now, you can either:

1. use width() instead 
2. use manual instantiation, i.e. add the following
right before main() in exa05_main.cxx:

#ifdef __DECCXX // workaround V5.5 auto instantiation bug
#include "exa05.cxx" 
#pragma define_template exa05<char>
#endif
3503.3Thanx for the FAST answersMUNICH::WWERNERWhen in doubt, do as the INTs doWed Mar 19 1997 10:120