Jump to content

Linker errors, i don't understand a single piece of it!


Guest lillecarl
 Share

Recommended Posts

Im trying to create a "Pet Creator NPC", so i got this code piece here: (Stolen from Spelleffects.cpp with a few edits so it compiles)

bool GossipSelect_beast_master(Player *pPlayer, Creature *pCreature, uint32 sender, uint32 action)
{	
if (pPlayer->getClass() == CLASS_HUNTER)
{
	ChatHandler(pPlayer->GetSession()).PSendSysMessage("Right after if (pPlayer->getClass() == CLASS_HUNTER)");
	Creature *creatureTarget = ChatHandler(pPlayer->GetSession()).getSelectedCreature();

	Pet* pPet = new Pet(HUNTER_PET);

	if(!pPet->CreateBaseAtCreature(creatureTarget))
	{
		delete pPet;
		return false;
	}

	pPet->SetOwnerGuid(pPlayer->GetObjectGuid());
	pPet->SetCreatorGuid(pPlayer->GetObjectGuid());
	pPet->setFaction(pPlayer->getFaction());
	pPet->SetUInt32Value(UNIT_CREATED_BY_SPELL, 13481);

	if (pPlayer->IsPvP())
		pPet->SetPvP(true);

	if (!pPet->InitStatsForLevel(creatureTarget->getLevel()))
	{
		sLog.outError("Pet::InitStatsForLevel() failed for creature (Entry: %u)!",creatureTarget->GetEntry());
		delete pPet;
		return false;
	}

	pPet->GetCharmInfo()->SetPetNumber(sObjectMgr.GeneratePetNumber(), true);
	// this enables pet details window (Shift+P)
	pPet->AIM_Initialize();
	pPet->InitPetCreateSpells();
	pPet->SetHealth(pPet->GetMaxHealth());

	// "kill" original creature
	creatureTarget->ForcedDespawn();

	// prepare visual effect for levelup
	pPet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()-1);

	// add to world
	pPet->GetMap()->Add((Creature*)pPet);

	// visual effect for levelup
	pPet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel());

	// caster have pet now
	pPlayer->SetPet(pPet);

	pPet->SavePetToDB(PET_SAVE_AS_CURRENT);
	pPlayer->PetSpellInitialize();
}
return true;
}

And when i try to compile it, i get this linker errors:

1>npc_scripts.obj : error LNK2019: unresolved external symbol "public: void __thiscall Map::Add<class Creature>(class Creature *)" ([email protected]@@@[email protected]@[email protected]@@Z) referenced in function "bool __cdecl GossipSelect_beast_master(class Player *,class Creature *,unsigned int,unsigned int)" ([email protected]@[email protected]@[email protected]@[email protected])

1>npc_scripts.obj : error LNK2019: unresolved external symbol "public: void __thiscall CharmInfo::SetPetNumber(unsigned int,bool)" ([email protected]@@[email protected]) referenced in function "bool __cdecl GossipSelect_beast_master(class Player *,class Creature *,unsigned int,unsigned int)" ([email protected]@[email protected]@PAVCreatu[email protected]@[email protected])

1>npc_scripts.obj : error LNK2019: unresolved external symbol "public: void __cdecl Log::outError(char const *,...)" ([email protected]@@QAAXPBDZZ) referenced in function "bool __cdecl GossipSelect_beast_master(class Player *,class Creature *,unsigned int,unsigned int)" ([email protected]@[email protected]@[email protected]@[email protected])

1>npc_scripts.obj : error LNK2019: unresolved external symbol "public: unsigned int __thiscall IdGenerator<unsigned int>::Generate(void)" ([email protected][email protected]@@QAEIXZ) referenced in function "public: unsigned int __thiscall ObjectMgr::GeneratePetNumber(void)" ([email protected]@@QAEIXZ)

1>npc_scripts.obj : error LNK2001: unresolved external symbol "private: static bool MaNGOS::Singleton<class ObjectMgr,class MaNGOS::SingleThreaded<class ObjectMgr>,class MaNGOS::OperatorNew<class ObjectMgr>,class MaNGOS::ObjectLifeTime<class ObjectMgr> >::si_destroyed" ([email protected][email protected]@@[email protected]@@@[email protected]@[email protected]@@@[email protected][email protected]@@@[email protected]@[email protected]@0_NA)

1>npc_scripts.obj : error LNK2001: unresolved external symbol "private: static class ObjectMgr * MaNGOS::Singleton<class ObjectMgr,class MaNGOS::SingleThreaded<class ObjectMgr>,class MaNGOS::OperatorNew<class ObjectMgr>,class MaNGOS::ObjectLifeTime<class ObjectMgr> >::si_instance" ([email protected][email protected]@@[email protected]@@@[email protected]@[email protected]@@@[email protected][email protected]@@@[email protected]@[email protected]@[email protected]@A)

1>npc_scripts.obj : error LNK2019: unresolved external symbol "public: __thiscall ObjectMgr::ObjectMgr(void)" ([email protected]@[email protected]) referenced in function "public: static class ObjectMgr * __cdecl MaNGOS::OperatorNew<class ObjectMgr>::Create(void)" ([email protected][email protected]@@@[email protected]@[email protected]@XZ)

1>npc_scripts.obj : error LNK2019: unresolved external symbol "public: __thiscall ObjectMgr::~ObjectMgr(void)" ([email protected]@[email protected]) referenced in function "public: void * __thiscall ObjectMgr::`scalar deleting destructor'(unsigned int)" ([email protected]@[email protected])

1>npc_scripts.obj : error LNK2001: unresolved external symbol "private: static bool MaNGOS::Singleton<class Log,class MaNGOS::SingleThreaded<class Log>,class MaNGOS::OperatorNew<class Log>,class MaNGOS::ObjectLifeTime<class Log> >::si_destroyed" ([email protected][email protected]@@[email protected]@@@[email protected]@[email protected]@@@[email protected][email protected]@@@[email protected]@[email protected]@0_NA)

1>npc_scripts.obj : error LNK2001: unresolved external symbol "private: static class Log * MaNGOS::Singleton<class Log,class MaNGOS::SingleThreaded<class Log>,class MaNGOS::OperatorNew<class Log>,class MaNGOS::ObjectLifeTime<class Log> >::si_instance" ([email protected][email protected]@@[email protected]@@@[email protected]@[email protected]@@@[email protected][email protected]@@@[email protected]@[email protected]@[email protected]@A)

1>npc_scripts.obj : error LNK2019: unresolved external symbol "private: __thiscall Log::Log(void)" ([email protected]@[email protected]) referenced in function "public: static class Log * __cdecl MaNGOS::OperatorNew<class Log>::Create(void)" ([email protected][email protected]@@@[email protected]@[email protected]@XZ)

1>..\\..\\..\\..\\bin\\win32_release/mangosscript.dll : fatal error LNK1120: 11 unresolved externals

And the sad part about this is that, however much i read on MSDN and forums, i do not understand anything! I would atleast want a hint in the correct direction, because i really wanna learn how you fix those linker errors, they have been a mess before. I mean the outlog calls can just be removed, but adding the pet to the world etc.. is pretty much needed.

EDIT: Solved a few now by changing:

struct CharmInfo
into
struct MANGOS_DLL_SPEC CharmInfo

EDIT2: Solved even another by changing:

class IdGenerator
into
class MANGOS_DLL_SPEC IdGenerator


Those left:

1>npc_scripts.obj : error LNK2019: unresolved external symbol "public: void __thiscall Map::Add<class Creature>(class Creature *)" ([email protected]@@@[email protected]@[email protected]@@Z) referenced in function "bool __cdecl GossipSelect_beast_master(class Player *,class Creature *,unsigned int,unsigned int)" ([email protected]@[email protected]@[email protected]@[email protected])
1>npc_scripts.obj : error LNK2001: unresolved external symbol "private: static bool MaNGOS::Singleton<class ObjectMgr,class MaNGOS::SingleThreaded<class ObjectMgr>,class MaNGOS::OperatorNew<class ObjectMgr>,class MaNGOS::ObjectLifeTime<class ObjectMgr> >::si_destroyed" ([email protected][email protected]@@[email protected]@@@[email protected]@[email protected]@@@[email protected][email protected]@@@[email protected]@[email protected]@0_NA)
1>npc_scripts.obj : error LNK2001: unresolved external symbol "private: static class ObjectMgr * MaNGOS::Singleton<class ObjectMgr,class MaNGOS::SingleThreaded<class ObjectMgr>,class MaNGOS::OperatorNew<class ObjectMgr>,class MaNGOS::ObjectLifeTime<class ObjectMgr> >::si_instance" ([email protected][email protected]@@[email protected]@@@[email protected]@[email protected]@@@[email protected][email protected]@@@[email protected]@[email protected]@[email protected]@A)
1>npc_scripts.obj : error LNK2019: unresolved external symbol "public: __thiscall ObjectMgr::ObjectMgr(void)" ([email protected]@[email protected]) referenced in function "public: static class ObjectMgr * __cdecl MaNGOS::OperatorNew<class ObjectMgr>::Create(void)" ([email protected][email protected]@@@[email protected]@[email protected]@XZ)
1>npc_scripts.obj : error LNK2019: unresolved external symbol "public: __thiscall ObjectMgr::~ObjectMgr(void)" ([email protected]@[email protected]) referenced in function "public: void * __thiscall ObjectMgr::`scalar deleting destructor'(unsigned int)" ([email protected]@[email protected])
1>..\\..\\..\\..\\bin\\win32_release/mangosscript.dll : fatal error LNK1120: 5 unresolved externals

EDIT: I fixed it by creating a function in player.cpp containing the code instead and call it from the script, it works. But it surely is not the "correct way" in my opinion, so i would like to know how you fix the linker errors still =)

Thanks in advance

- Carl

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use