On 7/24/2015 11:13 AM, Ruben Van Boxem wrote:
> 2015-07-24 17:03 GMT+02:00 Edward Diener <[email protected]
> <mailto:[email protected]>>:
>
>     On 7/24/2015 8:54 AM, Riot wrote:
>     > Where are you defining your template, in the header or the source? You
>     > may need to explicitly instantiate.
>
>     The template is being defined in the YY.cpp source file.
>
>
> Could you send example files displaying the issue? It makes it easier to
> reproduce and debug the issue.

Yes, of course. I first wanted to see if anybody had encountered the 
general problem. I will work on reducing the problem down to the 
shortest possible example, along with the command lines for creating the 
shared library and the executable, and then post it in this thread. It 
will probably take a little while as the actual examples I am using is 
still too large to make it easy to reproduce.

>
> Thanks,
>
> Ruben
>
>
>      >
>      > On 24 Jul 2015 13:31, "Edward Diener"
>     <[email protected]
>     <mailto:[email protected]>
>      > <mailto:[email protected]
>     <mailto:[email protected]>>> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to