我有一個名爲 「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