未解决的外部符号

时间:2012-08-06 04:03:00

标签: c++ dll unresolved-external

我在编译DLL项目时得到了这个:

  

错误1错误LNK2019:未解析的外部符号“public:unsigned char * __thiscall CDetour :: GetThisPtr(void)”(?GetThisPtr @ CDetour @@ QAEPAEXZ)在函数“void __stdcall zCharacter_OnDamagedHook”中引用(struct ZObject *,struct D3DXVECTOR3, int,int,float,float,int)“(?zCharacter_OnDamagedHook @@ YGXPAUZObject @@ UD3DXVECTOR3 @@ HHMMH @ Z)C:\ Users \Andrés\ Documents \ Visual Studio 2010 \ Projects \ 2k7_A-H \ 2k7_A-H \ AntiLead .obj 2k7_A-H

我在哪里使用“zCharacter_OnDamagedHook”就在这里:

void __stdcall zCharacter_OnDamagedHook(ZObject* pAttacker, D3DXVECTOR3 srcPos, int damageType, int weaponType, float fDamage, float fPiercingRatio, int nMeleeType) {
    zCharacter_OnDamagedDetour.Ret(true);
    std::string channelName = ZGameClient::GetInstance()->CurrentChannel;
    ZCharacter* victim = (ZCharacter*)zCharacter_OnDamagedDetour.GetThisPtr();
    ZCharacter* attacker = (ZCharacter*)pAttacker;
    ZCharacter* me = (ZCharacter*)ZGame::GetInstance()->pMyCharacter;
    if ((channelName.find("[No-Lead]") == std::string::npos) && (channelName.find("[No-Lead]") == std::string::npos)) {
        ZCharacterManager* charm = ZCharacterManager::GetInstance();
        if (((attacker == me) && (victim != me)) && (damageType != 5) && (damageType != 1) && (damageType != 2)) {
            zCharacter_OnDamagedDetour.Ret(false);
            MUID uidVictim;
            for (unsigned int i = 0; i < muidList.size(); ++i) {
                if (charm->Find(muidList[i]) == victim) {
                    uidVictim = muidList[i];
                    break;
                }
            }
            MCommand* pCmd = MCommand::Create(0xD3D9);
            pCmd->AddParameter(new MCommandParameterInt(uidVictim.lowId));
            pCmd->AddParameter(new MCommandParameterFloat(srcPos.x));
            pCmd->AddParameter(new MCommandParameterFloat(srcPos.y));
            pCmd->AddParameter(new MCommandParameterFloat(srcPos.z));
            pCmd->AddParameter(new MCommandParameterInt(damageType));
            pCmd->AddParameter(new MCommandParameterInt(weaponType));
            pCmd->AddParameter(new MCommandParameterFloat(fDamage));
            pCmd->AddParameter(new MCommandParameterFloat(fPiercingRatio));
            pCmd->AddParameter(new MCommandParameterInt(nMeleeType));
            MCommand::Post(pCmd);
        }

我真的不知道我做错了什么,之前我没有得到这个错误所以我希望有人可以帮助我,提前做好。

1 个答案:

答案 0 :(得分:3)

您的CDetour类已声明成员函数GetThisPtr,但您的源(.cpp)文件均未提供定义。

由于您没有显示任何代码,因此无法进一步评论。