C++ Shared Library with Templates: Undefined symbols error

后端 未结 4 1384
广开言路
广开言路 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条回答
  •  猫巷女王i
    2020-12-04 11:29

    You need to include the implementation of the template classes in the header files as well. This is a constraint of templates in C++. So either include shared.cpp from main (#include ) or just move the code from shared.cpp in shared.h

提交回复
热议问题