Where are you defining your template, in the header or the source? You may need to explicitly instantiate. On 24 Jul 2015 13:31, "Edward Diener" <eldlistmaili...@tropicsoft.com> wrote:
> Before attempting to reduce my code to a small enough example to post > here in its entirety I will give a description of the problem to see if > anyone has encountered it in general. The problem is purely a linker > problem. > > I have an exported class in a shared library, called it XX in header > file XX.hpp. From an executable's source file, called it YY.cpp I > include the class's header file where the class will show as imported > and in the code in the source file I throw an exception with an instance > of the class, as in: > > throw XX(some_constructor_parameters); > > This compiles and links without error. > > If instead I use a template to throw an exception, such as: > > template<class E> void throw_exception(E const & e) { throw e; } > > and then invoke it from my executable as: > > throw_exception(XX(some_constructor_parameters)); > > I receive a linker error of the form: > > YY.o: In function `SomeDecoratedName': > XX.hpp:27: undefined reference to `vtable for XX' > XX.hpp:27: undefined reference to `vtable for XX' > > I realize that this is not a complete example but before reducing my > code to the least possible example which will reproduce this problem I > thought I would ask if anyone has encountered anything like it, or has > any idea why using a template causes a linker error whereas not using > the template links would link without any problems. > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Mingw-w64-public mailing list > Mingw-w64-public@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public >
------------------------------------------------------------------------------
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public