Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 96306 - gcc-3.3.5-r1 fails to link against some template (instanciation problem?)
Summary: gcc-3.3.5-r1 fails to link against some template (instanciation problem?)
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL: http://gcc.gnu.org/bugzilla/show_bug....
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-16 13:56 UTC by Masse Nicolas
Modified: 2005-06-27 21:53 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
sources who causes the problem (sources.tar.gz,3.02 KB, application/x-gzip)
2005-06-16 13:57 UTC, Masse Nicolas
Details
sources showing the problem with gcc3.4.3 (sources_gcc3.4.tar.gz,3.07 KB, application/x-gzip)
2005-06-22 05:57 UTC, Masse Nicolas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Masse Nicolas 2005-06-16 13:56:08 UTC
I'm trying to do a program in c++, but when I try to compile, it doesn't works.
The code is attached to this message.

Just know that I have a template class (SuffixTree) used in the main func. The
problem seems to be that the method of this class aren't instanciated like they
have to be.
Since it doesn't seems to me I made a mistake, I assume this is a gcc bug. But
perhaps am I wrong. If so, just tell me (in fact I'm new in using templates).

Also note I already try to force the instanciation by adding the line :
template class SuffixTree<int>; 
in some file, but all it does was worst than what I already have.



Reproducible: Always
Steps to Reproduce:
1.compile the different files (works just fine)
2.Try to link them in order to create the executable
3.it fails

Actual Results:  
reports these

test_suffix_node.o(.text+0xc2): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::insert(int&, char
const*)'
test_suffix_node.o(.text+0xcd): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::print_tree()'
test_suffix_node.o(.text+0x11b): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::key_exist(char const*)'
test_suffix_node.o(.text+0x1ba): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::print_tree()'
collect2: ld a retourn
Comment 1 Masse Nicolas 2005-06-16 13:56:08 UTC
I'm trying to do a program in c++, but when I try to compile, it doesn't works.
The code is attached to this message.

Just know that I have a template class (SuffixTree) used in the main func. The
problem seems to be that the method of this class aren't instanciated like they
have to be.
Since it doesn't seems to me I made a mistake, I assume this is a gcc bug. But
perhaps am I wrong. If so, just tell me (in fact I'm new in using templates).

Also note I already try to force the instanciation by adding the line :
template class SuffixTree<int>; 
in some file, but all it does was worst than what I already have.



Reproducible: Always
Steps to Reproduce:
1.compile the different files (works just fine)
2.Try to link them in order to create the executable
3.it fails

Actual Results:  
reports these

test_suffix_node.o(.text+0xc2): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::insert(int&, char
const*)'
test_suffix_node.o(.text+0xcd): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::print_tree()'
test_suffix_node.o(.text+0x11b): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::key_exist(char const*)'
test_suffix_node.o(.text+0x1ba): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::print_tree()'
collect2: ld a retourné 1 code d'état d'exécution

Expected Results:  
create the executable

Portage 2.0.51.19 (default-linux/x86/2005.0, gcc-3.3.5, glibc-2.3.4.20041102-r1,
2.6.11-gentoo-r4 i686)
=================================================================
System uname: 2.6.11-gentoo-r4 i686 AMD Athlon(tm) XP 2000+
Gentoo Base System version 1.4.16
Python:              dev-lang/python-2.3.4-r1 [2.3.4 (#1, Apr  5 2005, 17:51:08)]
dev-lang/python:     2.3.4-r1
sys-apps/sandbox:    [Not Present]
sys-devel/autoconf:  2.13, 2.59-r6
sys-devel/automake:  1.5, 1.8.5-r3, 1.7.9-r1, 1.6.3, 1.4_p6, 1.9.4
sys-devel/binutils:  2.15.92.0.2-r1
sys-devel/libtool:   1.5.10-r4
virtual/os-headers:  2.6.8.1-r2
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-O3 -march=athlon-xp -fomit-frame-pointer -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config
/usr/lib/X11/xkb /usr/share/config /usr/share/texmf/dvipdfm/config/
/usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/
/usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O3 -march=athlon-xp -fomit-frame-pointer -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs autoconfig ccache distlocks sandbox sfperms strict"
GENTOO_MIRRORS="http://mirror.datapipe.net/gentoo
http://mirror.datapipe.net/gentoo http://gentoo.inode.at/"
LANG="fr_FR@euro"
LC_ALL="fr_FR@euro"
LINGUAS="fr fr_FR"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="x86 3dnow X Xaw3d aalib acl acpi adns alsa apm arts audiofile avi berkdb
bitmap-fonts bonobo cdr crypt cscope cups curl dga directfb divx4linux doc dvd
dvdr emboss encode esd evo fam fastcgi fbcon flac foomaticdb fortran gb gd gdbm
gif gnome gphoto2 gpm gstreamer gtk gtk2 gtkhtml guile imagemagick imap imlib
innodb ipv6 java jikes joystick jpeg junit kerberos krb4 ldap libg++ libwww mad
mikmod mmx motif mozilla mp3 mpeg msn ncurses nls nocd ogg oggvorbis opengl oss
pam pdf pdflib perl png python qt quicktime readline samba scanner sdl slang
spell sse ssl svga svgalib szip tcltk tcpd tetex tiff truetype truetype-fonts
type1-fonts unicode usb videos vorbis wmf wxwindows xine xml xml2 xmms xv xvid
zlib video_cards_radeon linguas_fr linguas_fr_FR userland_GNU kernel_linux
elibc_glibc"
Unset:  ASFLAGS, CBUILD, CTARGET, LDFLAGS, PORTDIR_OVERLAY
Comment 2 Masse Nicolas 2005-06-16 13:57:57 UTC
Created attachment 61350 [details]
sources who causes the problem
Comment 3 SpanKY gentoo-dev 2005-06-17 07:35:02 UTC
fails to even compile for me:

suffix_node.cc: In member function `bool cpl::internals::SuffixNode<T>::key_exist(const char*)':
suffix_node.cc:89: warning: there are no arguments to `get_subnode' that depend on a template parameter, so a declaration of `get_subnode' must be available
suffix_node.cc: In member function `cpl::internals::SuffixNode<T>& cpl::internals::SuffixNode<T>::insert(T&, const char*)':
suffix_node.cc:123: warning: there are no arguments to `get_subnode' that depend on a template parameter, so a declaration of `get_subnode' must be available
suffix_node.cc:127: error: `subNodes' undeclared (first use this function)
suffix_node.cc:127: error: (Each undeclared identifier is reported only once for each function it appears in.)
Comment 4 Masse Nicolas 2005-06-17 07:48:21 UTC
Are you using gcc3.4 series? if so, you need to add this-> before some
declaration (those who causes problems). I tested that today, and once you've
done it... same result as with gcc3.3.5: problem when linking.
If you want, I can send you the corrected sources.
Comment 5 Masse Nicolas 2005-06-21 14:23:56 UTC
I think it was closed a little too fast....
Comment 6 SpanKY gentoo-dev 2005-06-21 15:12:46 UTC
posted updated sources that dont bomb/dump warnings with gcc-3.4
Comment 7 Masse Nicolas 2005-06-22 05:57:36 UTC
Created attachment 61715 [details]
sources showing the problem with gcc3.4.3

with these files, I get this:


test_suffix_node.o(.text+0x1bd): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::insert(int&, char
const*)'
test_suffix_node.o(.text+0x1c8): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::print_tree()'
test_suffix_node.o(.text+0x215): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::key_exist(char
const*)'
test_suffix_node.o(.text+0x2b4): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::print_tree()'
test_suffix_node.o(.gnu.linkonce.r._ZTVN3cpl9internals10SuffixNodeIiEE+0x8):
undefined reference to `cpl::internals::SuffixNode<int>::~SuffixNode()'
test_suffix_node.o(.gnu.linkonce.r._ZTVN3cpl9internals10SuffixNodeIiEE+0xc):
undefined reference to `cpl::internals::SuffixNode<int>::~SuffixNode()'
test_suffix_node.o(.gnu.linkonce.r._ZTVN3cpl9internals10SuffixTreeIiEE+0x8):
undefined reference to `cpl::internals::SuffixTree<int>::~SuffixTree()'
test_suffix_node.o(.gnu.linkonce.r._ZTVN3cpl9internals10SuffixTreeIiEE+0xc):
undefined reference to `cpl::internals::SuffixTree<int>::~SuffixTree()'
collect2: ld a retourn
Comment 8 Masse Nicolas 2005-06-22 05:57:36 UTC
Created attachment 61715 [details]
sources showing the problem with gcc3.4.3

with these files, I get this:


test_suffix_node.o(.text+0x1bd): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::insert(int&, char
const*)'
test_suffix_node.o(.text+0x1c8): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::print_tree()'
test_suffix_node.o(.text+0x215): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::key_exist(char
const*)'
test_suffix_node.o(.text+0x2b4): In function `main':
: undefined reference to `cpl::internals::SuffixTree<int>::print_tree()'
test_suffix_node.o(.gnu.linkonce.r._ZTVN3cpl9internals10SuffixNodeIiEE+0x8):
undefined reference to `cpl::internals::SuffixNode<int>::~SuffixNode()'
test_suffix_node.o(.gnu.linkonce.r._ZTVN3cpl9internals10SuffixNodeIiEE+0xc):
undefined reference to `cpl::internals::SuffixNode<int>::~SuffixNode()'
test_suffix_node.o(.gnu.linkonce.r._ZTVN3cpl9internals10SuffixTreeIiEE+0x8):
undefined reference to `cpl::internals::SuffixTree<int>::~SuffixTree()'
test_suffix_node.o(.gnu.linkonce.r._ZTVN3cpl9internals10SuffixTreeIiEE+0xc):
undefined reference to `cpl::internals::SuffixTree<int>::~SuffixTree()'
collect2: ld a retourné 1 code d'état d'exécution
Comment 9 SpanKY gentoo-dev 2005-06-22 16:39:40 UTC
that version fails for gcc-3.3.[56] gcc-3.4.[34] and gcc-4.0.0
also tested with binutils-2.15 / 2.15.92.0.2 / 2.16 / 2.16.90.0.3

you should file a bug in the gcc bugzilla:
http://gcc.gnu.org/bugzilla/

they'll be able to properly help you
Comment 10 Masse Nicolas 2005-06-27 15:05:26 UTC
I've posted it on the gcc bugzilla,
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22161) seems it comes from me...

Sorry for the disagrement.
Comment 11 SpanKY gentoo-dev 2005-06-27 21:53:23 UTC
np

see how they were able to give you such a fast answer ? :)