C++ Shared Library with Templates: Undefined symbols error

后端 未结 4 1363
广开言路
广开言路 2020-12-04 11:08

I\'m trying to link to a shared library with a template class, but it is giving me \"undefined symbols\" errors. I\'ve condensed the problem to about 20 lines of code.

4条回答
  •  温柔的废话
    2020-12-04 11:24

    The compiler has to see all the code for a template, so it can generate the appropriate code for the actual type you want to use. So you should place all the code in your .h. file.

提交回复
热议问题