Jump to content
  • Advertisement
Sign in to follow this  
SteveDeFacto

Lerp function help!

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

In my library I define my lerp function like this in math.h:



template <typename T>
__declspec(dllexport) T Lerp( T& val1, T& val2, float u);


Next in math.cpp the function looks like this:




template <typename T>
T Lerp( T& val1, T& val2, float u)
{
return (1 - u) * val1 + u * val2;
}


When I call the lerp function in my library I get unresolved external symbol. I've never used a template before so that's probably what's wrong.

Share this post


Link to post
Share on other sites
Advertisement
You can't put template functions in .cpp files like that. The compiler has to be able to see the entire definition. There were some attempts to address these with the export keyword but this has been dropped by the standards committee.

You either put the function definition in the header file, or include the definitions at the bottom of the header.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!