I have a C++ project that due to its directory structure is set up as a static library A, which is linked into shared library B, which is linked in
If you can use C++0x features of gcc (-std=c++0x), then the function default template arguments may do the trick. As of the current c++ standard, default arguments are not allowed for function templates. With these enabled in c++0x, you can do something like :-
In some header file of static library ...
template< class T = int >
void Af()
{
}
Then in its corresponding cpp file use explicit template instantiation...
template void Af();
This will generate the symbols for the function Af though it is not yet called/referenced.
This won't affect the callers due to the fact that because of the default template argument, you need not specify a type. Just add the template before the function declaration and explicitly instantiate it in its implementation file.
HTH,