specifying object code (/additional libraries) to be linked -- where?
Hello,
I get "undefined reference to ..." linker errors.
My definitions reside in a cpp file which do get compiled to object code.
If I put the definitions inside the header file, the link process is without errors.
Thus I guess that the link process inside QtCreator forgets to link the object code it created from my cpp files.
Where do I specify the files to be linked?
Or is this a different problem?
Please help!
Thanks
Lars
Re: specifying object code (/additional libraries) to be linked -- where?
btw. here's the implementation:
Code:
#include "Y.h"
template<class X> Y<X>::~Y()
{
delete Something;
}
It's defined in Y.cpp.
If I put this code inside the header file Y.h, there are no problems. If I leave the code here, I get
Code:
release/Z.o:Z.cpp::-1: error: undefined reference to `Y<_mytype>::~Y()'
. Z.cpp includes Y.h.
Re: specifying object code (/additional libraries) to be linked -- where?
see http://www.linuxforums.org/forum/lin...ce-errors.html.
Template classes must be declared and defined in one file, ie. putting implementation in cpp doesn't work as the specific type to be used in the template is unknown on compile time thus the compiler can't generate code for the implementation (having the implementation included in the file which is included in the code where the template is instantiated makes the type in the template known.)