I have a shared library which contains the definition of a template class. I am instantiating the template class in a main file and compiling with gcc but it is giving me a lot of problems. It seems that the gcc compiler does not have visibility to template definitions if the template definition and instantiation are done at different places. Now I know that one way to solve this problem is to pull out the definitions and put it in the translation unit where it is actually getting instantiated but that is simply not feasible in my application as it implies that I have to do #include of the cpp file where the definition resides at hundreds of places inside my code. Another option would be to place my template definition within my header files which are anyway included at places where the template is being instantiated. But there is a problem with this solution too. We have a SDK that we make available to the end customer and this SDK includes the header files. So if we were to put the template defintions in the header files we would be exposing our code which is not what we want. I have tried all the template related options of the g++ compiler such as -fno-implicit-templates, -fexternal-templates and -falt-external-templates but to no avail.
Can someone please lead me to a simple and elegant solution?
Can someone please lead me to a simple and elegant solution?