//本错误系原创,如有雷同,纯属缘分啊~~~:(//我想给100000分来求答案,,但是这里只允许100分,我没办法,//####################################################################
-----------       错误      ------------------------
Vector.obj : error LNK2005: "float __cdecl math_sqrtf(float)" (?math_sqrtf@@YAMM@Z) already defined in test.obj
Vector.obj : error LNK2005: "void __cdecl math_BuildSqrtTable(void)" (?math_BuildSqrtTable@@YAXXZ) already defined in test.obj
---------  以下省略3000行 :( ---------------//-----------函数代码 In :  math.h   ---------------------
#pragma once
#pragma warning (disable : 4035)float math_sqrtf( float r );float math_sqrtf( float r ) 
{
__asm {
     fld r
     fsqrt
    }
}
//----------------  Over --------------------
我实在不知道这里有什么问题,,,只包含这个头文件一次,就正常,包含两次就LINK2005。。
瞎搞中,把math_sqrtf(float ) 修改为inline ,,,又OK了,,晕,这和inline有什么关系啊???
反正这样可以了,,,VC这东西也就这样子啦,继续写我的其它代码,于是写了个CRay,再编译Ok,      LinK....2001
//#################################################################
//---------------   错误:   ----------------------
error LNK2001: unresolved external symbol "public: class CVector & __thiscall CVector::operator=(class CVector const &)" (??4CVector@@QAEAAV0@ABV0@@Z)
//--------------  没有省略  -----------------------
//--------------函数代码: In  Vector.h --------------
#pragma once
class CVector
{
.......
   inline CVector& operator=( const CVector &V );
......
};
// in Vector.cpp 
.................
inline CVector &CVector::operator=( const CVector &V ) 
{
x = V.x;
y = V.y;
z = V.z;
return *this;
}
................
//----------------   Over   ----------------------我这次把inline去掉了,,又好了,,很郁闷啊,别的不说,我这个类里面有19个运算符重载函数,都是inline 的 ,其它18个为什么都OK,就这个不行?种族歧视?
我找不到理由去掉这个inline....希望各位能告诉我。################################
总之,我还是去掉了inline,接着写其它的代码,,,
然后再编译,OK。LINK。。2001。
Triangle.obj : error LNK2001: unresolved external symbol "public: float const  __thiscall CVector::operator%(class CVector const &)const " (??LCVector@@QBE?BMABV0@@Z)
Triangle.obj : error LNK2001: unresolved external symbol "public: void __thiscall CVector::Normalize(void)" (?Normalize@CVector@@QAEXXZ)
Triangle.obj : error LNK2001: unresolved external symbol "public: __thiscall CVector::CVector(class CVector const &)" (??0CVector@@QAE@ABV0@@Z)
Triangle.obj : error LNK2001: unresolved external symbol "public: class CVector const  __thiscall CVector::operator-(class CVector const &)const " (??GCVector@@QBE?BV0@ABV0@@Z)
Triangle.obj : error LNK2001: unresolved external symbol "public: class CVector const  __thiscall CVector::operator+(class CVector const &)const " (??HCVector@@QBE?BV0@ABV0@@Z)
Triangle.obj : error LNK2001: unresolved external symbol "public: class CVector const  __thiscall CVector::operator*(float)const " (??DCVector@@QBE?BV0@M@Z)
Triangle.obj : error LNK2001: unresolved external symbol "public: float __thiscall CVector::Distance(class CVector const &)" (?Distance@CVector@@QAEMABV1@@Z)
God........save me.....

解决方案 »

  1.   

    inline 函数必须在头文件中实现
      

  2.   

    .h里面只是声明变量和函数的地方(变量和函数头前加extern),变量的定义和函数的实现放在.c或者.cpp文件中加上inline关键字后成了内联函数,就可以放在头文件中了
      

  3.   

    刚才一直上不来,连接数据库错误。
    谢谢几位。
    该揭帖了,哈哈,
    没办法,我觉得我可以不用cpp了,因为我的一些3D数学类成员函数全部都是内联+汇编,又不能用extern,所以只好用h就够了,哈哈,,,,打开一个文件夹,里面全是*.h  有点不习惯啊~~~~搞定....