[Trilinos-Users] [EXTERNAL] Question About Template Specialization in .hpp Files
Bradley, Andrew Michael
ambradl at sandia.gov
Sat Nov 5 18:38:21 EDT 2016
Hi Corey,
Thanks for the bug report. I believe you are correct. I have recorded the problem in our issue tracker:
https://github.com/trilinos/Trilinos/issues/782
Andrew
________________________________________
From: Trilinos-Users <trilinos-users-bounces at trilinos.org> on behalf of Corey A. Henderson <cahenderson at wisc.edu>
Sent: Saturday, November 5, 2016 4:30 PM
To: trilinos-users at trilinos.org
Subject: [EXTERNAL] [Trilinos-Users] Question About Template Specialization in .hpp Files
I recently chased down a linker problem in a code I'm writing, where I
was getting "multiple definition" errors when I added
MueLu_CreateEpetraPreconditioner.hpp. Specifically
CreateEpetraPreconditioner and ReuseEpetraPreconditioner. I was able
to work around it by ensuring I only include this .hpp file from one
compilation unit, but in researching my problem I learned that
template specializations shouldn't be in .hpp files for this very
reason.
EG: http://stackoverflow.com/questions/4445654/multiple-definition-of-template-specialization-when-using-different-objects
So far as I can tell (Trilinos v12.8.1) there is no way to include
this .hpp file in two different compilation units successfully. I did
configure Trilinos with the Trilinos_ENABLE_EXPLICIT_INSTANTIATION
option ON. I'm not sure if that makes a difference.
Should this code (the template specializations) be in a .cpp file and
thus in the libraries? Or am I missing something?
Corey
--
Corey A. Henderson
PhD Candidate and NSF Graduate Fellow
Dept. of Engineering Physics
Univ. of Wisconsin - Madison
_______________________________________________
Trilinos-Users mailing list
Trilinos-Users at trilinos.org
https://trilinos.org/mailman/listinfo/trilinos-users
More information about the Trilinos-Users
mailing list