我有一个头文件在库(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