发信人: kkay(kkay), 信区: C
标 题: 求助:动态库中导出类成员模版
发信站: 饮水思源 (2014年10月29日09:18:40 星期三)

我有一个模版类,但不想开放源码,所以想通过显示实例化的方式导出到dll文件中,大致
如下:
.h文件中
template <typename T>
class __declspec(dllexport) A
{
public:
A(void);
~A(void);
public:
template <typename U>
void Func(U);
};
.cc文件中
template <typename T>
A<T>::A(void)
{
}

template <typename T>
A<T>::~A(void)
{
}

template <typename T>
template <typename U>
void A<T>::Func(U)
{
}
template class A<int>;
template void A<int>::Func(float);

我查看了一下生成的lib文件,结果如下:
Dump of file DLL-EXP.lib
File Type: LIBRARY
Exports
ordinal name
??0?$A@H@@QAE@XZ (public: __thiscall A<int>::A<int>(void))
??1?$A@H@@QAE@XZ (public: __thiscall A<int>::~A<int>(void))
??4?$A@H@@QAEAAV0@ABV0@@Z (public: class A<int> & __thiscall
A<int>::operator=(class A<int> const &))
也就是说A<int>::Func(float)并没有被导出。
问题出在哪里啊?


--
hello
※ 来源:·饮水思源 bbs.sjtu.edu.cn·[FROM: 202.101.41.1]