On Sunday, December 13, 2015 at 6:45:55 PM UTC+1, Wolfgang Bangerth wrote:
>
> On 12/13/2015 10:36 AM, David W. wrote: 
> > Hi all, 
> > 
> > I defined a class template `FEM<dim>` in a header file, 
> > and in the main.cc file I set `dimension=3`, calling the 
> > constructor `FEM<dimension> fem`. But when I `make` 
> > it, an error message appeared. I have tried one day long 
> > to debug the code, but still have no idea where the problem 
> > is. Here is the error message: 
> > 
> > | 
> > CMakeFiles/main.dir/main.cc.o:Infunction`main` 
> > /home/ubuntu/debug/main.cc:29:undefinedreference to 
> > `FEM<3>::generate_mesh(std::vector<unsigned int, std::allocator<unsigned 
> int> >)` 
> > |/home/ubuntu/debug/main.cc:30:undefinedreference to 
> `FEM<3>::setup_system()`| 
> > ||/home/ubuntu/debug/main.cc:31:undefinedreference to 
> > `FEM<3>::assemble_system()`|| 
> > ||/home/ubuntu/debug/main.cc:32:undefinedreference to `FEM<3>::solve()` 
> > ||||||/home/ubuntu/debug/main.cc:33:undefinedreference to 
> > `FEM<3>::output_results()` 
> > ||||||collect2: error: 1d returned 1 exit status 
> > make[2]: *** [main] Error 1 
> > make[1]: *** [CMakeFiles/main.dir/all] Error 2 
> > make: *** [all] Error 2 
> > || 
> > | 
>
> If you *define* the member functions the template class in one .cc file, 
> but 
> *use* them in another, you need to make sure that the class and its 
> functions 
> are actually instantiated somewhere. To this end, you want to put the 
> following line at the bottom of the .cc file in which you define the 
> member 
> functions of your class: 
>    template class FEM<3>; 
> This is called an "explicit instantiation". 
>
> Thanks Prof Bangerth. This answer was helpful to me!

Regards,
Vinayak Gholap

-- 
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