Jump to content
  • Advertisement
Sign in to follow this  
Geometrian

LNK2019 Templates

This topic is 2736 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
Looks like VS2010 at least supports "export". For portability, I moved all the template functions into the header file, which seems to have fixed it.
Thanks,
G

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
I didn't try to implement the code using it (for portability), but typing "export" seemed to be recognized, so I assumed it was usable for the compiler.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!