我有一個頭文件在庫(alibrary.lib)。該庫是一個靜態庫(.lib),它正確鏈接到exe。C++:頭文件函數沒有正確鏈接從庫到exe
現在,我有一個類:Vector3d。
class Vector3d
{
void amethod()
{
blah
}
};
Vector3d cross(const Vector3d &v0, const Vector3d &v1)
{
float x,y,z;
x = v0.y*v1.z-v0.z*v1.y;
y = v0.z*v1.x-v0.x*v1.z;
z = v0.x*v1.y-v0.y*v1.x;
return Vector3d(x,y,z);
}
的Vector3D被聲明和在頭文件(的Vector3D .h)中所定義。在類聲明之後,我是交叉函數。
的LIB編譯是文件,但是當它鏈接到單元測試的exe我得到這個錯誤:
flywindow.obj :error LNK2005: "class Vector3d __cdecl cross(class Vector3d const &,class Vector3d const &)" ([email protected]@[email protected]@[email protected]@Z) already defined in fly.obj
任何想法?
感謝
內聯工作。謝謝 – cbrulak 2009-02-01 05:35:02