Templates can be a problem if not handled correctly. The build process works roughly as follows: the preprocessor modifies the source in accordance with preprocessor definition. The compiler compiles that source, resorting to declarations as a guideline. The compiler does not have to know the contents of external procedures or variables, just how to use them.

The compiler compiles additional sources, as single entities, according to the same guidelines. The linker puts it all together, requring that code exists that conforms to the specification of mere guidelines (declarations) which were enough to satisfy the compiler.

Remember that the compiler is only dealing with one file at a time (as modified or clarified by included files, which are pasted in by the preprocessor).

This means that when there is an attempt to expand upon and produce code for a template, that information must be available immediately. This immediacy is not satisfied by information contained in a compilation that may or may not have been produced at a given point in the build process.

Put yourself in the position of the compiler. If all the required information is not available in the source file, as modified by include files, then you just can't succeed.