我有一个名为 “SimObject” 一类:无法导出模板功能
namespace simBase
{
class __declspec(dllexport) SimObject: public SimSomething
{
public:
template <class T>
void updateParamValue(const std::string& name, T val);
}
}
我有一个名为 “ITerrainDrawable” 其他类:
namespace simTerrain
{
class __declspec(dllexport) ITerrainDrawable : public simBase::SimObject
{
}
}
这些类不同的库。 SimObject在simBase中,ITerrainDrawable在simTerrain库中。即使ITerrainDrawable从SimObject衍生和我包括simBase的图书馆,我得到一个链接错误:
unresolved external symbol
1>ITerrainDrawable.obj : error LNK2019: unresolved external symbol "public: void __thiscall simBase::SimObject::updateParamValue<float>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,float)" ([email protected]@[email protected]@@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]) referenced in function "public: void __thiscall simTerrain::ITerrainDrawable::setTerrainSize(float)" ([email protected]@[email protected]@[email protected])
1>ITerrainDrawable.obj : error LNK2019: unresolved external symbol "public: void __thiscall simBase::SimObject::updateParamValue<class osg::Vec4f>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class osg::Vec4f)" ([email protected]@[email protected]@@[email protected]@@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@@Z) referenced in function "public: void __thiscall simTerrain::ITerrainDrawable::setSatelliteTextureBorders(class osg::Vec2f,class osg::Vec2f)" ([email protected]@[email protected]@[email protected]@@[email protected])
为什么我得到这个错误?
一切工作正常,如果我不使用模板功能,但我需要它。
如果我将这个函数移动到simTerrain函数库中,它工作正常,但我不想使用重复函数,因为有许多类似simTerrain的函数库。
谢谢尼尔:)它工作时,我将函数定义的标题 – ufukgun 2009-12-28 13:02:18