Hello Wolfgang,

Yes, I do explicitly instantiate these templates in my code. The datatype 
is different from what is already defined in deal.II. Something like:
#include <deal.II/lac/vector.h>
#include <deal.II/lac/vector.templates.h>
template class Vector<myNumberClass>;

But these two guys:
dealii::Vector<std::complex<float> >::operator=(std::complex<float>)
and
dealii::Vector<int>::lp_norm(int) const
are explicitly instantiated in vector.templates.h (lines 855 and 1476). So, 
if the file vector.templates.h is included in two source files there will 
be a linker error. And vector.templates.h is already included in 
lac/vector.cc, therefore the multiple definition error mentioning that 
file. The solution is to either put them into some source file in the 
library (i.e. in vector.cc) or mark them as inline. Probably better to 
place them into a source file.
What do you think?

Dragan

On Saturday, September 10, 2016 at 5:17:26 PM UTC+1, Wolfgang Bangerth 
wrote:
>
>
> Dragan, 
>
> > I need to use Vector FullMatrix, BlockVector and BlockSparseMatrix with 
> > different datatype than what is already provided and instantiated 
> (float, 
> > double...). I have the following problem when instantiating with a 
> different 
> > type: the linking fails due to the multiple definitions of the following 
> > functions: 
> > vector.cc:-1: error: multiple definition of 
> > `dealii::Vector<std::complex<float> >::operator=(std::complex<float>)' 
> > vector.cc:-1: error: multiple definition of 
> `dealii::Vector<int>::lp_norm(int) 
> > const' 
> > 
> > These two functions are explicitly instantiated in vector.templates.h 
> for 
> > float and int types. But, if I instantiate Vector<myNumber> in my code 
> these 
> > two definitions will appear in both files (vector.cc and my source file) 
> even 
> > though I use a different type. 
>
> Correct. Do you *explicitly* instantiate these classes in your code? If 
> you 
> do, why? If they're already explicitly instantiated in the library, you do 
> not 
> need to add explicit instantiations in your own code. 
>
>
> > Could you please let me know if there is a reason to instantiate them in 
> the 
> > header file rather than in the source vector.cc file? 
>
> ?? Can you point out where it is instantiated in the .h file? I think the 
> only 
> file is in the .inst file, which is #included in the .cc file. 
>
> Best 
>   Wolfgang 
>
> -- 
> ------------------------------------------------------------------------ 
> Wolfgang Bangerth          email:                 [email protected] 
> <javascript:> 
>                             www: http://www.math.colostate.edu/~bangerth/ 
>
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to