In c++, templates are just a meta-definition of an actual class. When you compile a templated class, the compiler actually generates the code for the actual class on the fly for the particular type of data passed in (the template is just a "pattern" to copy).
e.g. If you have the following code
struct MyTemplate
{
private:
float MyValue;
public:
float Get() { return MyValue; }
void Set(float value) { MyValue = value; }
};
void main()
{
MyTemplate v1;
MyTemplate v2;
v1.Set(5.0f);
v2.Set(2);
v2.Get();
}
What the compiler actually sees is
struct CompilerGeneratedNameFor_MyTemplate_float
{
private:
float MyValue;
public:
float Get() { return MyValue; }
void Set(float value) { MyValue = value; }
};
struct CompilerGeneratedNameFor_MyTemplate_int
{
private:
int MyValue;
public:
int Get() { return MyValue; }
void Set(int value) { MyValue = value; }
};
void main()
{
CompilerGeneratedNameFor_MyTemplate_float v1;
CompilerGeneratedNameFor_MyTemplate_int v2;
v1.Set(5.0f);
v2.Set(2);
v2.Get();
}
As you can probably see, the compiler doesn't actually know what code to generate, until you actually declare an instance of your template. This means that the template can't be compiled into a library, because it doesn't know what the template will actually end up being. The good news about this is that you don't actually need ANY library to be compiled or included if you just distribute the header files that include the template definition.
Also, as a side note, the '#include' pre-compiler command actually just tells the pre-compiler to replace the '#include' with everything from that file.