[EMAIL PROTECTED] wrote: > g.h : > template <class T> > void g (T x); > > g.cc : > template <class T> > void g (T x) { > cout << x; > } > > The .h file has to include the .cc one in order for the compilation to work. > That leads to a shared library that we'll call libg.so.1.0.0 > Let's say now that I compile a program `prgm` and link it against the above > library.
There are two issues here. The first is that you are not really linking against the code in the shared library. GCC does not support template export (for damn good reasons, really), and certainly does not support it through shared libraries. In all likelyhood, the compiler is actually inlining g(). If you were really using the shared library, you would not have to include the .cc file. You're not. Your .so most likely does not even export the instantiation of g<T> you need. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]