A template implementation must be visible at compile time. The code you show as "struct.cpp" should be part of "struct.h", not in its own file. Then when "mainwindow" is compiled, the template will be found.