This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
egcs 1.1.2 on HPUX 10 20 bug: static members in a template class
- To: "'egcs-bugs at egcs dot cygnus dot com'" <egcs-bugs at egcs dot cygnus dot com>
- Subject: egcs 1.1.2 on HPUX 10 20 bug: static members in a template class
- From: "Tsirkin, Michael" <michael dot tsirkin at intel dot com>
- Date: Sun, 30 May 1999 10:00:22 -0700
Hello!
I have build egcs 1.1.2 with GAS on HPPA 10.20 system.
I have trouble linking C++ code that uses template classes
with static members. Yes I have read the FAQ.
Could someone help?
Please mail any suggestions to mailto:mtsirkin@iil.intel.com
Thank you,
MST
Here is the code in question:
////////////////////
template <class T> class X {
public: static int i;
};
template <class T> int X<T>::i=0;
int main() {
return X<long>::i;
}
////////////////////////////////
This code compiles and runs on my Linux box, but on HP it produces a linkage
error:
g++ t.cpp
/bin/ld: Unsatisfied symbols:
X<long>::i(data)
collect2: ld returned 1 exit status
////////////////////////////////
Note that this code also compiles with the HP C++ compiler aC++.
////////////////////////////////
G++ info:
>g++ -v
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
>g++ -dumpspecs
*asm:
*asm_final:
*cpp:
%{!mpa-risc-1-0:%{!mnosnake:%{!msoft-float:-D__hp9000s700 -D_PA_RISC1_1}}}
%{!ansi: -D_HPUX_SOURCE -D_HIUX_SOURCE} %{threads:-D_REENTRANT
-D_DCE_THREADS}
*cc1:
%{pg:} %{p:}
*cc1plus:
*endfile:
*link:
%{!mpa-risc-1-0:%{!shared:-L/lib/pa1.1 -L/usr/lib/pa1.1 }} -z
%{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{shared:-b}
*lib:
%{!shared: %{!p: %{!pg: %{!threads:-lc}
%{threads:-lcma -lc_r}} %{p: -L/lib/libp/ -lc} %{pg:
-L/lib/libp/ -lc}}}
*libgcc:
-lgcc
*startfile:
%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}}
*switches_need_spaces:
*signed_char:
%{funsigned-char:-D__CHAR_UNSIGNED__}
*predefines:
-Dhppa -Dhp9000s800 -D__hp9000s800 -Dhp9k8 -DPWB -Dhpux -Dunix
-Asystem(unix) -Asystem(hpux) -Acpu(hppa) -Amachine(hppa)
*cross_compile:
0
*version:
egcs-2.91.66
*multilib:
. !threads;threads threads;
*multilib_defaults:
*multilib_extra:
*multilib_matches:
threads threads;
*linker:
collect2
>g++ -dumpmachine
hppa1.1-hp-hpux10.20
Please let me know if any additional info is required.
I noticed the "Please see the file BUGS (included with the sources) first"
at the
end of the g++ message, but I was unable to locate the BUGS file.
If my message has a wrong format, could you please be so kind to
send this file to me?
Thank you,
MST