Can't figure what's causing this error.

Some background information:

I'm using SFML 1.6 in Code::Blocks 10.05
I'm trying to create a function that will do something to a sf::Vector2<T>.
I want to put this functions declaration in a .hpp separate from the main function, and it's implementation in a separate .cpp file.

Here is the bare minimum of what I am trying to do:

main.cpp
1
2
3
4
5
6
7
8
#include <SFML/Graphics.hpp>
#include "A.hpp"

int main()
{
	sf::Vector2<int> v;
	foo(v);
}


A.hpp
1
2
3
4
#include <SFML/Graphics.hpp>

template <typename T>
void foo(sf::Vector2<T>&);


A.cpp
1
2
3
4
5
6
7
#include "A.hpp"

template <typename T>
void foo(sf::Vector2<T>&)
{

}


Here is the compile error in Code::Blocks 10.05
obj\Debug\main.o||In function `main':|
C:\...\main.cpp|7|undefined reference to `void foo<int>(sf::Vector2<int>&)'|
||=== Build finished: 1 errors, 0 warnings ===|


What does undefined reference mean? I thought it meant the function is not implemented, or it can't find the implementation of the declaration. Looks like it should work though.
Template functions need to be implemented in headers (visible to whatever is using them).
Ok, that fixed it. Thanks.
Topic archived. No new replies allowed.