Linking problems with templates.
Chalapathi R. Emani
cemani@qualcomm.com
Tue Nov 16 15:41:00 GMT 1999
Hi,
I am trying to use the latest version from cygwin and
I am having linking problems with a file that uses templates:
When I compiled one of the source file I got the following warnings:
Config.h:178: warning: friend declaration `class istream & operator >>(class
ream &, class OrderedTriple<T> &)'
Config.h:178: warning: declares a non-template function
Config.h:178: warning: (if this is not what you intended, make sure
Config.h:178: warning: the function template has already been declared,
Config.h:178: warning: and add <> after the function name here)
Config.h:179: warning: friend declaration `class ostream & operator
<<(class ost
ream &, class OrderedTriple<T> &)'
Config.h:179: warning: declares a non-template function
Config.h:231: warning: friend declaration `class istream & operator
>>(class ist
ream &, class OrderedPair<T> &)'
Config.h:231: warning: declares a non-template function
Config.h:232: warning: friend declaration `class ostream & operator
<<(class ost
ream &, class OrderedPair<T> &)'
Config.h:232: warning: declares a non-template function
When I linked this file to libstdc++.a I got linker errors that said:
/examples/scs_sid/Config.cxx:29: undefined reference to `operator>>(istream &
rderedPair<int> &)'
/examples/scs_sid/Config.cxx:29: undefined reference to `operator>>(istream &
rderedPair<double> &)'
/examples/scs_sid/Config.cxx:29: undefined reference to `operator>>(istream &
rderedTriple<int> &)'
These have been defined in the header file itself.
I went ahead and compiled this with the flag "-fguiding-decls" and these
warnings have gone away.
Then I tried linking this with the rest of the objects and libstdc++.a and
I am getting the following
errors:
C:\cygnus\cygwin-b20\H-i586-cygwin32\bin\..\lib\gcc-lib\i586-cygwin32\egcs-2
.91.
57\..\..\../libstdc++.a(ldcomplex.o)(.text+0x13c):cinst.cc: multiple definition
of `operator/(complex<long double> const &, long double)'
Config.o(.text$__dv__FRCt7complex1Zrr+0x0):/examples/scs_sid/\\cygnus\\cygwi
n-b2
0\\H-i586-cygwin32\\lib\\gcc-lib\\i586-cygwin32\\egcs-2.91.57\\..\\..\\..\\.
.\\.
.\\include\\g++\\stl_list.h: first defined here
C:\cygnus\cygwin-b20\H-i586-cygwin32\bin\..\lib\gcc-lib\i586-cygwin32\egcs-2
.91.
57\..\..\../libstdc++.a(dcomplex.o)(.text+0x128):cinst.cc: multiple
definition o
f `operator/(complex<double> const &, double)'
Config.o(.text$__dv__FRCt7complex1Zdd+0x0):/examples/scs_sid/\\cygnus\\cygwi
n-b2
0\\H-i586-cygwin32\\lib\\gcc-lib\\i586-cygwin32\\egcs-2.91.57\\..\\..\\..\\.
.\\.
.\\include\\g++\\stl_list.h: first defined here
C:\cygnus\cygwin-b20\H-i586-cygwin32\bin\..\lib\gcc-lib\i586-cygwin32\egcs-2
.91.
57\..\..\../libstdc++.a(fcomplex.o)(.text+0xf8):cinst.cc: multiple
definition of
`operator/(complex<float> const &, float)'
Config.o(.text$__dv__FRCt7complex1Zff+0x0):/examples/scs_sid/\\cygnus\\cygwi
n-b2
0\\H-i586-cygwin32\\lib\\gcc-lib\\i586-cygwin32\\egcs-2.91.57\\..\\..\\..\\.
.\\.
.\\include\\g++\\stl_list.h: first defined here
collect2: ld returned 1 exit status
The problem is that I am not seeing the reference to "operator/ ...."
anywhere either in my code
or in stl-list.h or any other header files. But somehow the linker keeps
saying that there are
multiple definitions.
On Solaris when I use the "-fguiding-decls" option and compile and link
it, it builds just fine.
May be because I use 2.8.1 on Solaris.
Do you know if the above option has been deprecated in Cygwin 2.95.2 ?
Thanks a lot for your help.
Chalapathi.
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
More information about the Cygwin
mailing list