我在MSVC调试版本中遇到错误LNK2019,因为函数' doSomething'的代码结构类型如下。代码编译很好,以优化构建。有人可以帮忙吗?
//头文件 - abc.h
class __declspec(dllimport) Test /* some functions of class Test are defined in DLL - abc */ {
// members
public:
template <typename T>
_forceinline int doSomething(T var)
{
//do some thing
return var.size();
}
}
// cpp file
/*part of another DLL which does not link to DLL 'abc' */
#include "abc.h"
int main() {
Test t;
Test1 var1;
t.doSomething( var1 );
}