Sign in to follow this  
SteveDeFacto

Lerp function help!

Recommended Posts

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


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

Next in math.cpp the function looks like this:


[code]

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

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

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