Bug 22161 - Template linking error
Summary: Template linking error
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3.5
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-23 13:14 UTC by Masse Nicolas
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
code who causes the problem (3.10 KB, application/x-gzip)
2005-06-23 13:16 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-23 13:14:52 UTC
Most of the bug is described here:
http://bugs.gentoo.org/show_bug.cgi?id=96306

It seems to be a template instanciation problem. 
When I try to compile a program, 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()'
Comment 1 Masse Nicolas 2005-06-23 13:16:24 UTC
Created attachment 9133 [details]
code who causes the problem
Comment 2 Andrew Pinski 2005-06-23 13:24:29 UTC
This is not a bug, this is how C++ templates work.  You want to include templates functions in the 
same TU as the where you use them.  Unless you use export but export is not implemented yet.
Comment 3 Masse Nicolas 2005-06-27 22:02:49 UTC
hmmmm well. I made an include at the end of my file... it works now. But this is
not a nice solution I find. 
Well, I'll continue that way for now, and wait for the export method to be
implemented. I will also have a look at the gcc doc on that subject.

Thanks for all.