Sign in to follow this  

LNK2019 Templates

This topic is 2542 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
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

This topic is 2542 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this