U
Uwe Mayer
Hi,
I am writing a library, which contains classes with template
memberfunctions. If I do not instanciate the templates I want to use, I get
an "undefined reference" link-error.
The FAQ
(http://www.new-brunswick.net/workshop/c++/faq/templates.html#faq-35.15)
explained I had to explicitly name the instanciations I wanted to use. That
works, but is awfully tedious.
The gcc manual
(http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/Template-Instantiation.html#Template-Instantiation)
suggests the use of the -frepo flag.
1. Did I understand it correctly, that this is supposed to handle the
automatic template instanciation, at the cost of longer compile /link time?
2. This also doesn't work. "collect2" is called, and the .rpo files are
generated, but now I even get a link error on something that looks like its
comming from STL:
[...]
collect: recompiling test6.cpp
collect: relinking
collect: recompiling test6.cpp
collect: relinking
test6-test6.o: In function `main':
test6.cpp:48: undefined reference to `ml::LinePlot&
ml::Axes:lot3<gsl_vector>(gsl_vector*, gsl_vector*, gsl_vector*, char*)'
libmatplot.so: undefined reference to `std::_Rb_tree<double,
std:air<double const, ml::Axes*>, std::_Select1st<std:air<double const,
ml::Axes*> >, std::less<double>, std::allocator<std:air<double const,
ml::Axes*> > >::_M_erase(std::_Rb_tree_node<std:air<double const,
ml::Axes*> >*)'
Any ideas?
Thanks in advance
Ciao
Uwe
I am writing a library, which contains classes with template
memberfunctions. If I do not instanciate the templates I want to use, I get
an "undefined reference" link-error.
The FAQ
(http://www.new-brunswick.net/workshop/c++/faq/templates.html#faq-35.15)
explained I had to explicitly name the instanciations I wanted to use. That
works, but is awfully tedious.
The gcc manual
(http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/Template-Instantiation.html#Template-Instantiation)
suggests the use of the -frepo flag.
1. Did I understand it correctly, that this is supposed to handle the
automatic template instanciation, at the cost of longer compile /link time?
2. This also doesn't work. "collect2" is called, and the .rpo files are
generated, but now I even get a link error on something that looks like its
comming from STL:
[...]
collect: recompiling test6.cpp
collect: relinking
collect: recompiling test6.cpp
collect: relinking
test6-test6.o: In function `main':
test6.cpp:48: undefined reference to `ml::LinePlot&
ml::Axes:lot3<gsl_vector>(gsl_vector*, gsl_vector*, gsl_vector*, char*)'
libmatplot.so: undefined reference to `std::_Rb_tree<double,
std:air<double const, ml::Axes*>, std::_Select1st<std:air<double const,
ml::Axes*> >, std::less<double>, std::allocator<std:air<double const,
ml::Axes*> > >::_M_erase(std::_Rb_tree_node<std:air<double const,
ml::Axes*> >*)'
Any ideas?
Thanks in advance
Ciao
Uwe