• Advertisement
Sign in to follow this  

LNK2019 Templates

This topic is 2617 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I have a template function, protoype:
template<typename type_float> void rotate_deg(type_float point[3], type_float vec[3], type_float theta);
Later, in my program, I call:
float v1[3] = {-1.0,0.0,-1.0};
float y_axis[3] = {0,1,0};
rotate_deg<float>(v1, y_axis, (float)xzangle);
Getting the following error:
error LNK2019:
unresolved external symbol "void __cdecl rotate_deg<float>(float * const,float * const,float)" (??$rotate_deg@M@@YAXQAM0M@Z)
referenced in function [long function definition]
What is the problem, and how can it be resolved?

Thanks,
-G

Share this post


Link to post
Share on other sites
Advertisement
Long story short template definitions can't be put into source files without either compiler support that practically no compilers come with (the export keyword) or explicit instantiation for each type used in the program. As a result templates are most often simply just defined completely in the headers.

Share this post


Link to post
Share on other sites
Did you actually try using it? If you do MSVC 2010 will spit out:

warning C4237: 'export' keyword is not yet supported, but reserved for future use

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement