hi, Wolfgang

Thank you for the tips, error gone.

In case anyone would search for solution for multiple sources layout link 
error in future, I would remark it a little bit:

This error is caused by a feature called instantiation controlling after 
c++11, see section 16.1.5 of *C++ Primer (C++11 S.B.Lippman etc)*. 
What it does is guarantee there is only one template instantiation 
definition over the whole source tree and their corresponding object files.
According this link stackoverflow link:
https://stackoverflow.com/questions/2351148/explicit-template-instantiation-when-is-it-used
and section 16.1.5 of *C++ Primer*, C++ 11 (and newer) achieves this by 
explicit instantiation definition of template in library source code.  

In my case, main.cc only knows the declaration by including header, but 
can't directly see mylib, where the pde_solver<> is defined. This results 
in main.cc.o doesn't have class instantiation.
Then I must add the unique definition of class instantiation i.e., template 
class pde_solver<3> into last line of mylib/source.cc.

best,
Timo
On Thursday, December 28, 2023 at 5:58:02 PM UTC+2 Wolfgang Bangerth wrote:

> On 12/28/23 06:48, timo Hyvärinen wrote:
> > 
> > Unfortunately, I keep getting the following error in linking step 
> between 
> > libmylib.a and main:
> > "/projappl/project_xxxx/PDE/main.cc:115:undefined reference to 
> > `MyNamespace_mpi::pde_solver<3>::pde_solver(unsigned int)
> >  /projappl/project_xxxx/PDE/main.cc:116: undefined reference to 
> > `MyNamespace_mpi::pde_solver<3>::run()'
>
> Timo:
> You need what is called an 'explicit instantiation'. If you search the 
> archives of this mailing list, you will find the issue discussed in more 
> detail.
>
> Best
> W.
>
> -- 
> ------------------------------------------------------------------------
> Wolfgang Bangerth email: bang...@colostate.edu
> 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 dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/71563f45-7dcd-4983-b8ba-47a22ebf5503n%40googlegroups.com.

Reply via email to